チェンジセット 94

差分発生行の前後
無視リスト:
コミット日時:
2010/02/28 22:28:26 (14 年前)
コミッタ:
sorshi
ログメッセージ:

SQLite採用

ファイル:

凡例:

変更無し
追加
削除
更新
コピー
移動
  • trunk/install/perl/addatq.pl

    r1 r94  
    1616use DBI; 
    1717use DBD::Pg; 
     18use DBD::SQLite; 
    1819use Schedule::At; 
    1920use Time::Local; 
     
    2122$path = $0; 
    2223$path =~ s/addatq.pl$//i; 
    23 if ($pwd ne "./"){ 
     24if ($path ne "./"){ 
    2425push( @INC, "$path"); 
    2526} 
     
    3839 
    3940#DB検索(TIDとStationIDからPIDへ) 
    40  $data_source = sprintf("dbi:%s:dbname=%s;host=%s;port=%d", 
    41                 $DBDriv,$DBName,$DBHost,$DBPort); 
    42          $dbh = DBI->connect($data_source,$DBUser,$DBPass) ||die $DBI::error;; 
     41$dbh = DBI->connect($DSN,$DBUser,$DBPass) ||die $DBI::error;; 
    4342 
    4443if ($station == 0){ 
    45         $DBQuery =  "SELECT count(*) FROM  foltia_tvrecord WHERE tid = '$tid'  "; 
     44    $sth = $dbh->prepare($stmt{'addatq.1'}); 
     45    $sth->execute($tid); 
    4646}else{ 
    47         $DBQuery =  "SELECT count(*) FROM  foltia_tvrecord WHERE tid = '$tid' AND stationid  = '$station' "; 
     47    $sth = $dbh->prepare($stmt{'addatq.2'}); 
     48    $sth->execute($tid, $station); 
    4849} 
    49          $sth = $dbh->prepare($DBQuery); 
    50         $sth->execute(); 
    5150 @titlecount = $sth->fetchrow_array; 
    5251#件数数える 
     
    5453#2以上だったら 
    5554if ($titlecount[0]  >= 2){ 
    56         #全曲取りが含まれているか調べる 
    57         $DBQuery =  "SELECT count(*) FROM  foltia_tvrecord WHERE tid = '$tid'  AND  stationid  ='0' "; 
    58         $kth = $dbh->prepare($DBQuery); 
    59         $kth->execute(); 
     55    #全局録りが含まれているか調べる 
     56    $kth = $dbh->prepare($stmt{'addatq.3'}); 
     57    $kth->execute($tid); 
    6058        @reservecounts = $kth->fetchrow_array; 
    6159 
     
    6361                if($tid == 0){ 
    6462                #今回の引き数がSID 0だったら 
    65                #全局取りだけ予約 
    66 #               &writelog("addatq  DEBUG; ALL STATION RESERVE. TID=$tid SID=$station $titlecount[0] match:$DBQuery"); 
     63            #全局録りだけ予約 
     64#               &writelog("addatq  DEBUG; ALL STATION RESERVE. TID=$tid SID=$station $titlecount[0] match:$stmt{'addatq.3'}"); 
    6765                &addcue; 
    6866                }else{ 
    6967                #ほかの全局録画addatqが予約入れてくれるからなにもしない 
    70 #               &writelog("addatq  DEBUG; SKIP OPERSTION. TID=$tid SID=$station $titlecount[0] match:$DBQuery"); 
     68#               &writelog("addatq  DEBUG; SKIP OPERSTION. TID=$tid SID=$station $titlecount[0] match:$stmt{'addatq.3'}"); 
    7169                exit; 
    7270                }#end if ふくまれていたら 
     
    7573                &addcue; 
    7674}else{ 
    77 &writelog("addatq  error; reserve impossible . TID=$tid SID=$station $titlecount[0] match:$DBQuery"); 
     75    &writelog("addatq  error; reserve impossible . TID=$tid SID=$station $titlecount[0] match:$stmt{'addatq.3'}"); 
    7876} 
    7977 
     
    8280#       & addcue; 
    8381# }else{ 
    84 #&writelog("addatq  error record TID=$tid SID=$station $titlecount[0] match:$DBQuery"); 
     82#&writelog("addatq  error record TID=$tid SID=$station $titlecount[0] match:$stmt{'addatq.3'}"); 
    8583#} 
    8684 
     
    8886 
    8987if ($station == 0){ 
    90         $DBQuery =  "SELECT * FROM  foltia_tvrecord WHERE tid = '$tid'  "; 
     88        $sth = $dbh->prepare($stmt{'addatq.addcue.1'}); 
     89        $sth->execute($tid); 
    9190}else{ 
    92         $DBQuery =  "SELECT * FROM  foltia_tvrecord WHERE tid = '$tid' AND stationid  = '$station' "; 
     91        $sth = $dbh->prepare($stmt{'addatq.addcue.2'}); 
     92        $sth->execute($tid, $station); 
    9393} 
    94  $sth = $dbh->prepare($DBQuery); 
    95 $sth->execute(); 
    9694 @titlecount= $sth->fetchrow_array; 
    9795$bitrate = $titlecount[2];#ビットレート取得 
    9896 
    9997#PID抽出 
    100 $now = &epoch2foldate(`date +%s`); 
    101 $twodaysafter = &epoch2foldate(`date +%s` + (60 * 60 * 24 * 2)); 
     98    $now = &epoch2foldate(time()); 
     99    $twodaysafter = &epoch2foldate(time() + (60 * 60 * 24 * 2)); 
    102100#キュー入れは直近2日後まで 
    103101if ($station == 0 ){ 
    104         $DBQuery =  " 
    105 SELECT * from foltia_subtitle WHERE tid = '$tid'  AND startdatetime >  '$now'  AND startdatetime < '$twodaysafter' "
     102        $sth = $dbh->prepare($stmt{'addatq.addcue.3'}); 
     103       $sth->execute($tid, $now, $twodaysafter)
    106104}else{ 
    107         $DBQuery =  " 
    108 SELECT * from foltia_subtitle WHERE tid = '$tid' AND stationid  = '$station'  AND startdatetime >  '$now'  AND startdatetime < '$twodaysafter' "; 
    109105#stationIDからrecch 
    110 $getrecchquery="SELECT stationid , stationrecch  FROM foltia_station where stationid  = '$station' "; 
    111  $stationh = $dbh->prepare($getrecchquery); 
    112         $stationh->execute(); 
     106        $stationh = $dbh->prepare($stmt{'addatq.addcue.4'}); 
     107        $stationh->execute($station); 
    113108@stationl =  $stationh->fetchrow_array; 
    114109$recch = $stationl[1]; 
    115 } 
    116110 
    117  $sth = $dbh->prepare($DBQuery); 
    118         $sth->execute(); 
     111        $sth = $dbh->prepare($stmt{'addatq.addcue.5'}); 
     112        $sth->execute($tid, $station, $now, $twodaysafter); 
     113    } 
    119114  
    120115while (($pid , 
     
    131126if ($station == 0 ){ 
    132127#stationIDからrecch 
    133 $getrecchquery="SELECT stationid , stationrecch  FROM foltia_station where stationid  = '$stationid' "; 
    134  $stationh = $dbh->prepare($getrecchquery); 
    135         $stationh->execute(); 
     128            $stationh = $dbh->prepare($stmt{'addatq.addcue.6'}); 
     129            $stationh->execute($stationid); 
    136130@stationl =  $stationh->fetchrow_array; 
    137131$recch = $stationl[1]; 
  • trunk/install/perl/addpidatq.pl

    r83 r94  
    1414use DBI; 
    1515use DBD::Pg; 
     16use DBD::SQLite; 
    1617use Schedule::At; 
    1718use Time::Local; 
     
    1920$path = $0; 
    2021$path =~ s/addpidatq.pl$//i; 
    21 if ($pwd ne "./"){ 
     22if ($path ne "./"){ 
    2223push( @INC, "$path"); 
    2324} 
     
    3637 
    3738#DB検索(PID) 
    38         my $data_source = sprintf("dbi:%s:dbname=%s;host=%s;port=%d", 
    39                 $DBDriv,$DBName,$DBHost,$DBPort); 
    40          $dbh = DBI->connect($data_source,$DBUser,$DBPass) ||die $DBI::error;; 
     39$dbh = DBI->connect($DSN,$DBUser,$DBPass) ||die $DBI::error;; 
    4140 
    42 $DBQuery =  "SELECT count(*) FROM  foltia_subtitle WHERE pid = '$pid' "; 
    43          $sth = $dbh->prepare($DBQuery); 
    44         $sth->execute(); 
     41$sth = $dbh->prepare($stmt{'addpidatq.1'}); 
     42$sth->execute($pid); 
    4543 @titlecount= $sth->fetchrow_array; 
    4644  
    4745 if ($titlecount[0]  == 1 ){ 
    48  
    49 $DBQuery =  "SELECT bitrate,digital FROM  foltia_tvrecord , foltia_subtitle  WHERE foltia_tvrecord.tid = foltia_subtitle.tid AND pid='$pid' "; 
    50  $sth = $dbh->prepare($DBQuery); 
    51 $sth->execute(); 
     46    $sth = $dbh->prepare($stmt{'addpidatq.2'}); 
     47    $sth->execute($pid); 
    5248 @titlecount= $sth->fetchrow_array; 
    5349$bitrate = $titlecount[0];#ビットレート取得 
     
    5955 
    6056#PID抽出 
    61 $now = &epoch2foldate(`date +%s`); 
     57    $now = &epoch2foldate(time()); 
    6258 
    6359#stationIDからrecch 
    64 $DBQuery =  "SELECT stationrecch,digitalch ,digitalstationband ,foltia_station.stationid  FROM foltia_station,foltia_subtitle WHERE foltia_subtitle.pid = '$pid'  AND  foltia_subtitle.stationid =  foltia_station.stationid "; 
    65  
    66  $stationh = $dbh->prepare($DBQuery); 
    67         $stationh->execute(); 
    68 @stationl =  $stationh->fetchrow_array; 
     60    $stationh = $dbh->prepare($stmt{'addpidatq.3'}); 
     61    $stationh->execute($pid); 
     62    @stationl =  $stationh->fetchrow_array(); 
    6963$recch = $stationl[0]; 
    7064if ($recch eq ""){ 
    71         &writelog("addpidatq ERROR recch is NULL:$DBQuery."); 
     65        &writelog("addpidatq ERROR recch is NULL:$stmt{'addpidatq.3'}."); 
    7266        exit 1; 
    7367} 
     
    8276        $digitalstationband = 0; 
    8377} 
    84 $DBQuery =  "SELECT  * FROM  foltia_subtitle WHERE pid='$pid' "; 
    85  $sth = $dbh->prepare($DBQuery); 
    86 $sth->execute(); 
     78    $sth = $dbh->prepare($stmt{'addpidatq.4'}); 
     79    $sth->execute($pid); 
    8780($pid , 
    8881$tid , 
  • trunk/install/perl/captureimagemaker.pl

    r83 r94  
    1414$path = $0; 
    1515$path =~ s/captureimagemaker.pl$//i; 
    16 if ($pwd ne "./"){ 
     16if ($path ne "./"){ 
    1717push( @INC, "$path"); 
    1818} 
     
    5656$date =~ s/[^0-9]//ig; 
    5757if ($date eq "" ){ 
    58         $date =  `date  +%Y%m%d` 
     58    $date = strftime("%Y%m%d", localtime); 
    5959} 
    6060#       print "DATE:$date\n"; 
     
    6565$time =~ s/[^0-9]//ig; 
    6666if ($time eq "" ){ 
    67         $time =  `date  +%H%M` 
     67    $time =  strftime("%H%M", localtime); 
    6868} 
    6969#       print "TIME:$time\n"; 
     
    119119# 10秒ごとに 
    120120if ($filename =~ /m2t$/){ 
    121         &writelog("captureimagemaker DEBUG mplayer -ss 00:00:10 -vo jpeg:outdir=$capimgdirname/$captureimgdir/ -vf scale=192:108 -ao null -sstep 9 -v 3 $recfolderpath/$filename"); 
    122         system ("mplayer -ss 00:00:10 -vo jpeg:outdir=$capimgdirname/$captureimgdir/ -vf scale=192:108 -ao null -sstep 9 -v 3 $recfolderpath/$filename"); 
     121        &writelog("captureimagemaker DEBUG mplayer -ss 00:00:10 -vo jpeg:outdir=$capimgdirname/$captureimgdir/ -vf scale=192:108 -ao null -sstep 9  $recfolderpath/$filename"); 
     122        system ("mplayer -ss 00:00:10 -vo jpeg:outdir=$capimgdirname/$captureimgdir/ -vf scale=192:108 -ao null -sstep 9  $recfolderpath/$filename"); 
     123        if(-e "$capimgdirname/$captureimgdir/00000001.jpg" ){ #$capimgdirname/$captureimgdir/があったらなにもしない         
     124        }else{ #空っぽなら再試行 
     125                        &writelog("captureimagemaker DEBUG RETRY mplayer -ss 00:00:10 -vo jpeg:outdir=$capimgdirname/$captureimgdir/ -vf framestep=300step,scale=192:108 -ao null $recfolderpath/$filename"); 
     126                system ("mplayer -ss 00:00:10 -vo jpeg:outdir=$capimgdirname/$captureimgdir/ -vf framestep=300step,scale=192:108 -ao null $recfolderpath/$filename"); 
     127        } 
     128         
    123129}else{ 
    124130        &writelog("captureimagemaker DEBUG mplayer -ss 00:00:10 -vo jpeg:outdir=$capimgdirname/$captureimgdir/ -vf crop=690:460:12:10,scale=160:120 -ao null -sstep 9 -v 3 $recfolderpath/$filename"); 
    125         system ("mplayer -ss 00:00:10 -vo jpeg:outdir=$capimgdirname/$captureimgdir/ -vf crop=690:460:12:10,scale=160:120 -ao null -sstep 9 -v 3 $recfolderpath/$filename"); 
     131        system ("mplayer -ss 00:00:10 -vo jpeg:outdir=$capimgdirname/$captureimgdir/ -vf crop=690:460:12:10,scale=160:120 -ao null -sstep 9 $recfolderpath/$filename"); 
     132        if(-e "$capimgdirname/$captureimgdir/00000001.jpg" ){ #$capimgdirname/ 
     133        }else{ 
     134        system ("mplayer -ss 00:00:10 -vo jpeg:outdir=$capimgdirname/$captureimgdir/ -vf framestep=300step,crop=690:460:12:10,scale=160:120 -ao null $recfolderpath/$filename"); 
     135        } 
    126136} 
    127137 
  • trunk/install/perl/changestbch.pl

    r1 r94  
    2626use DBI; 
    2727use DBD::Pg; 
     28use DBD::SQLite; 
    2829 
    2930$path = $0; 
    3031$path =~ s/changestbch.pl$//i; 
    31 if ($pwd ne "./"){ 
     32if ($path ne "./"){ 
    3233push( @INC, "$path"); 
    3334} 
     
    5455# pidから局(送出コマンド)調べる 
    5556#DB初期化 
    56         my $data_source = sprintf("dbi:%s:dbname=%s;host=%s;port=%d", 
    57                 $DBDriv,$DBName,$DBHost,$DBPort); 
    58          $dbh = DBI->connect($data_source,$DBUser,$DBPass) ||die $DBI::error;; 
     57        $dbh = DBI->connect($DSN,$DBUser,$DBPass) ||die $DBI::error;; 
    5958 
    60 $DBQuery =  "SELECT foltia_station.tunertype,foltia_station.tunerch ,foltia_station.stationrecch ,foltia_station.stationid FROM foltia_subtitle,foltia_station WHERE foltia_subtitle.stationid = foltia_station.stationid AND foltia_subtitle.pid =  '$pid' "; 
    61          $sth = $dbh->prepare($DBQuery); 
    62         $sth->execute(); 
     59        $sth = $dbh->prepare($stmt{'changestbch.1'}); 
     60        $sth->execute($pid); 
    6361 @chstatus = $sth->fetchrow_array; 
    6462        $tunertype = $chstatus[0]; 
  • trunk/install/perl/deletemovie.pl

    r83 r94  
    1717$path = $0; 
    1818$path =~ s/deletemovie.pl$//i; 
    19 if ($pwd ne "./"){ 
     19if ($path ne "./"){ 
    2020push( @INC, "$path"); 
    2121} 
  • trunk/install/perl/digitaltvrecording.pl

    r91 r94  
    2525$path = $0; 
    2626$path =~ s/digitaltvrecording.pl$//i; 
    27 if ($pwd ne "./"){ 
     27if ($path ne "./"){ 
    2828push( @INC, "$path"); 
    2929} 
     
    112112                &writelog("digitaltvrecording: DEBUG FILENAME ne null \$outputfile $outputfile "); 
    113113        }else{ 
    114                $outputfile .= `date  +%Y%m%d-%H%M --date "1 min "`
     114        $outputfile .= strftime("%Y%m%d-%H%M", localtime(time + 60))
    115115                chomp($outputfile); 
    116116                $outputfile .= ".m2t"; 
     
    193193                } 
    194194        }else{ # エラー b25とrecfriioがありません 
    195                 &writelog("digitaltvrecording :ERROR :recfriio or b25 not found. You must install $toolpath/b25 and $toolpath/recfriio."); 
     195                &writelog("digitaltvrecording :ERROR :recfriio or b25 not found. You must install $toolpath/perl/tool/b25 and $toolpath/perl/tool/recfriio."); 
    196196        exit 1; 
    197197        } 
     
    387387                        } 
    388388        }else{ # エラー recpt1がありません 
    389                 &writelog("digitaltvrecording :ERROR :recpt1  not found. You must install $toolpath/b25 and $toolpath/recpt1."); 
     389                &writelog("digitaltvrecording :ERROR :recpt1  not found. You must install $toolpath/tool/b25 and $toolpath/tool/recpt1."); 
    390390        $errorflag = 1; 
    391391        } 
     
    409409                        } 
    410410        }else{ # エラー recfriioがありません 
    411                 &writelog("digitaltvrecording :ERROR :recfriio  not found. You must install $toolpath/b25 and $toolpath/recfriio."); 
     411                &writelog("digitaltvrecording :ERROR :recfriio  not found. You must install $toolpath/perl/tool/b25 and $toolpath/perl/tool/recfriio."); 
    412412        exit 1; 
    413413        } 
  • trunk/install/perl/envpolicyupdate.pl

    r70 r94  
    1616use DBI; 
    1717use DBD::Pg; 
     18use DBD::SQLite; 
    1819 
    1920$path = $0; 
    2021$path =~ s/envpolicyupdate.pl$//i; 
    21 if ($pwd ne "./"){ 
     22if ($path ne "./"){ 
    2223push( @INC, "$path"); 
    2324} 
     
    3334eval "$returnparam\n"; 
    3435 
    35         my $data_source = sprintf("dbi:%s:dbname=%s;host=%s;port=%d", 
    36                 $DBDriv,$DBName,$DBHost,$DBPort); 
    37          $dbh = DBI->connect($data_source,$DBUser,$DBPass) ||die $DBI::error;; 
     36    $dbh = DBI->connect($DSN,$DBUser,$DBPass) ||die $DBI::error;; 
    3837 
    39 $DBQuery =  "SELECT userclass,name,passwd1 FROM foltia_envpolicy "; 
    40  
    41  $envph = $dbh->prepare($DBQuery); 
     38    $envph = $dbh->prepare($stmt{'envpolicyupdate.1'}); 
    4239        $envph->execute(); 
    4340 
  • trunk/install/perl/folprep.pl

    r1 r94  
    2323$path = $0; 
    2424$path =~ s/folprep.pl$//i; 
    25 if ($pwd ne "./"){ 
     25if ($path ne "./"){ 
    2626push( @INC, "$path"); 
    2727} 
  • trunk/install/perl/foltia_conf1.pl.template

    r83 r94  
    2828 
    2929#以下はデフォルトでインストールしてればいじらなくてもいい 
    30 $main::DBDriv="Pg"; 
    31 $main::DBHost="localhost"; 
    32 $main::DBPort="5432"; 
    33 $main::DBName="foltia"; 
     30 
     31## for postgresql 
     32#$main::DSN="dbi:Pg:dbname=foltia;host=localhost;port=5432"; 
     33#require 'db/Pg.pl'; 
     34 
     35## for sqlite 
     36$main::DSN="dbi:SQLite:dbname=/home/foltia/foltia.sqlite"; 
     37require 'db/SQLite.pl'; 
     38 
    3439$main::DBUser="foltia"; 
    3540$main::DBPass=""; 
  • trunk/install/perl/foltialib.pl

    r83 r94  
    44$path = $0; 
    55$path =~ s/foltialib.pl$//i; 
    6 if ($pwd ne "./"){ 
     6if ($path ne "./"){ 
    77push( @INC, "$path"); 
    88} 
     
    1313use DBI; 
    1414use DBD::Pg; 
    15  
    16  
    17          $DBDriv=$main::DBDriv; 
    18          $DBHost=$main::DBHost; 
    19          $DBPort=$main::DBPort; 
    20          $DBName=$main::DBName; 
     15use DBD::SQLite; 
     16use POSIX qw(strftime); 
     17 
     18$DSN=$main::DSN; 
    2119         $DBUser=$main::DBUser; 
    2220         $DBPass=""; 
     
    4745sub writelog{ 
    4846my $messages = $_[0]; 
    49 my $timestump = `date  +%Y/%m/%d_%H:%M:%S`
     47    my $timestump = strftime("%Y/%m/%d_%H:%M:%S", localtime)
    5048chomp($timestump); 
    5149if ($debugmode == 1){ 
     
    146144my $stationname =  $_[0] ; 
    147145my $stationid ; 
    148 my $DBQuery =  "SELECT count(*) FROM foltia_station WHERE stationname = '$item{ChName}'"; 
    149146 
    150147my $sth; 
    151         $sth = $dbh->prepare($DBQuery); 
    152        $sth->execute(); 
     148    $sth = $dbh->prepare($stmt{'foltialib.getstationid.1'}); 
     149    $sth->execute($item{'ChName'}); 
    153150 my  @stationcount; 
    154151 @stationcount= $sth->fetchrow_array; 
     
    156153if ($stationcount[0] == 1){ 
    157154#チャンネルID取得 
    158 $DBQuery =  "SELECT stationid,stationname FROM foltia_station WHERE stationname = '$item{ChName}'"; 
    159          $sth = $dbh->prepare($DBQuery); 
    160         $sth->execute(); 
     155        $sth = $dbh->prepare($stmt{'foltialib.getstationid.2'}); 
     156        $sth->execute($item{'ChName'}); 
    161157 @stationinfo= $sth->fetchrow_array; 
    162158#局ID 
     
    166162}elsif($stationcount[0] == 0){ 
    167163#新規登録 
    168 $DBQuery =  "SELECT max(stationid) FROM foltia_station"; 
    169          $sth = $dbh->prepare($DBQuery); 
     164        $sth = $dbh->prepare($stmt{'foltialib.getstationid.3'}); 
    170165        $sth->execute(); 
    171166 @stationinfo= $sth->fetchrow_array; 
     
    174169##$DBQuery =  "insert into  foltia_station values ('$stationid'  ,'$item{ChName}','0','','','','','','')"; 
    175170#新規局追加時は非受信局をデフォルトに 
    176 $DBQuery =  "insert into  foltia_station  (stationid , stationname ,stationrecch )  values ('$stationid'  ,'$item{ChName}','-10')"; 
    177  
    178          $sth = $dbh->prepare($DBQuery); 
    179         $sth->execute(); 
     171        $sth = $dbh->prepare($stmt{'foltialib.getstationid.4'}); 
     172        $sth->execute($stationid, $item{'ChName'}, -10); 
    180173#print "Add station;$DBQuery\n"; 
    181 &writelog("foltialib Add station;$DBQuery"); 
     174       &writelog("foltialib Add station;$stmt{'foltialib.getstationid.4'}"); 
    182175}else{ 
    183176 
     
    287280} 
    288281 
    289 my $DBQuery =  "SELECT pid FROM foltia_subtitle WHERE m2pfilename = '$m2pfilename' LIMIT 1 "; 
    290282my $sth; 
    291 $sth = $dbh->prepare($DBQuery); 
    292 $sth->execute(); 
    293 #print "$DBQuery\n"; 
     283    $sth = $dbh->prepare($stmt{'foltialib.getpidbympegfilename.1'}); 
     284    $sth->execute($m2pfilename); 
     285#print "$stmt{'foltialib.getpidbympegfilename.1'}\n"; 
    294286my @pidinfo = $sth->fetchrow_array; 
    295287my $pid  = $pidinfo[0]; 
     
    312304 
    313305if ($updatestatus > 0 ){ 
    314 my $DBQuery =  "UPDATE  foltia_subtitle SET filestatus = $updatestatus , lastupdate      = now() WHERE pid = $pid "; 
    315306my $sth; 
    316 $sth = $dbh->prepare($DBQuery); 
    317 $sth->execute(); 
     307       $sth = $dbh->prepare($stmt{'foltialib.changefilestatus.1'}); 
     308       $sth->execute($updatestatus, $pid); 
    318309return 1; 
    319310}else{ 
     
    351342} 
    352343 
    353 my $DBQuery =  "SELECT filestatus FROM foltia_subtitle  WHERE pid = $pid "; 
    354344my $sth; 
    355 $sth = $dbh->prepare($DBQuery); 
    356 $sth->execute(); 
     345    $sth = $dbh->prepare($stmt{'foltialib.getfilestatus.1'}); 
     346    $sth->execute($pid); 
    357347 
    358348my @statusinfo = $sth->fetchrow_array; 
  • trunk/install/perl/getxml2db.pl

    r82 r94  
    1919use DBI; 
    2020use DBD::Pg; 
     21use DBD::SQLite; 
    2122use Digest::MD5 qw(md5_hex); 
    2223 
    2324$path = $0; 
    2425$path =~ s/getxml2db.pl$//i; 
    25 if ($pwd ne "./"){ 
     26if ($path ne "./"){ 
    2627push( @INC, "$path"); 
    2728} 
     
    4849} 
    4950 
     51$dbh = DBI->connect($DSN,$DBUser,$DBPass) ||die $DBI::error;; 
    5052 
    51         my $data_source = sprintf("dbi:%s:dbname=%s;host=%s;port=%d", 
    52                 $DBDriv,$DBName,$DBHost,$DBPort); 
    53  
    54          $dbh = DBI->connect($data_source,$DBUser,$DBPass) ||die $DBI::error;; 
    55  
    56 #$dbh->{AutoCommit} = 0; 
     53$dbh->{AutoCommit} = 0; 
    5754 
    5855# If-Modified-Since使うように変更#2008/11/14  
     
    105102$programtitlename =~ s/\&gt\;/>/gi; 
    106103$programtitlename =~ s/\&amp\;/\&/gi; 
    107 $programtitle = $dbh->quote($programtitlename); 
     104#       $programtitle = $dbh->quote($programtitlename); 
     105        $programtitle = $programtitlename; 
    108106 
    109107Jcode::convert(\$item{ChName},'euc'); 
     
    115113$programSubTitle =~ s/\&gt\;/>/gi; 
    116114$programSubTitle =~ s/\&amp\;/\&/gi; 
    117 $programSubTitle = $dbh->quote($programSubTitle); 
     115#      $programSubTitle = $dbh->quote($programSubTitle); 
    118116 
    119117$offsetmin = $item{StOffset}/60; 
     
    127125#サブタイトル追加------------------------------------------------- 
    128126#番組があるか確認 
    129 $DBQuery =  "SELECT count(*) FROM foltia_program WHERE tid = '$item{TID}'"; 
    130          $sth = $dbh->prepare($DBQuery); 
    131         $sth->execute(); 
     127        $sth = $dbh->prepare($stmt{'getxml2db.1'}); 
     128        $sth->execute($item{TID}); 
    132129 @titlecount= $sth->fetchrow_array; 
    133130  
     
    137134#200412012359 
    138135$nomalstarttime = substr($sttime,8,4); 
    139 $DBQuery =  "insert into  foltia_program values ($item{TID},$programtitle,'','$nomalstarttime','$length','','','3','1','')"; 
    140 # $sth = $dbh->prepare($DBQuery); 
    141 # $sth->execute(); 
    142 $oserr = $dbh->do($DBQuery); 
    143 &writelog("getxml2db  ADD TV Progtam:$item{TID}:$programtitle"); 
    144136 
    145  
     137            $sth = $dbh->prepare($stmt{'getxml2db.2'}); 
     138            $oserr = $sth->execute($item{TID}, $programtitle, '', $nomalstarttime, $length, '', '', 3, 1, '', ''); 
     139            &writelog("getxml2db  ADD TV Progtam:$item{TID}:$programtitle"); 
    146140}else{ 
    147141#2006/2/26  
    148142#あったら、タイトル確認して 
    149 $DBQuery =  "SELECT title FROM foltia_program WHERE tid = '$item{TID}'"; 
    150          $sth = $dbh->prepare($DBQuery); 
    151         $sth->execute(); 
     143            $sth = $dbh->prepare($stmt{'getxml2db.3'}); 
     144            $sth->execute($item{TID}); 
    152145 @titlearray = $sth->fetchrow_array; 
    153146#更新などされてたらupdate 
    154147#print "$titlearray[0] / $programtitle\n"; 
    155148 if ($titlearray[0] ne "$programtitlename" ){ 
    156         $DBQuery =  "UPDATE  foltia_program  SET        title = $programtitle where  tid = '$item{TID}' "; 
    157 #         $sth = $dbh->prepare($DBQuery); 
    158 #       $sth->execute(); 
    159         $oserr = $dbh->do($DBQuery); 
     149                $sth = $dbh->prepare($stmt{'getxml2db.4'}); 
     150                $oserr = $sth->execute($programtitle, $item{TID}); 
    160151        &writelog("getxml2db  UPDATE TV Progtam:$item{TID}:$programtitle"); 
    161152 }#end if update 
     
    164155 
    165156#PIDがあるか確認 
    166 $DBQuery =  "SELECT count(*) FROM foltia_subtitle WHERE tid = '$item{TID}' AND pid =  '$item{PID}' "; 
    167          $sth = $dbh->prepare($DBQuery); 
    168         $sth->execute(); 
     157        $sth = $dbh->prepare($stmt{'getxml2db.5'}); 
     158        $sth->execute($item{'TID'}, $item{'PID'}); 
    169159 @subticount= $sth->fetchrow_array; 
    170160 if ($subticount[0]  >= 1){ 
     
    174164#UPDATE  foltia_subtitle  SET stationid = '42',countno = '8',subtitle = '京都行きます' ,startdatetime = '200503010035'  ,enddatetime = '200503010050',startoffset  = '0' ,lengthmin = '15' WHERE tid = '550' AND pid =  '26000'  
    175165if ($item{Count} == ""){ 
    176  
    177         $DBQuery =  "UPDATE  foltia_subtitle  SET  
    178         stationid = '$stationid', 
    179         countno =  null, 
    180         subtitle = $programSubTitle , 
    181         startdatetime = '$recstartdate'  , 
    182         enddatetime = '$recenddate', 
    183         startoffset  = '$offsetmin' , 
    184         lengthmin = '$length'  
    185         WHERE tid = '$item{TID}' AND pid =  '$item{PID}' "; 
    186  
     166                $sth = $dbh->prepare($stmt{'getxml2db.6'}); 
     167                $oserr = $sth->execute($stationid, undef, $programSubTitle, $recstartdate, $recenddate, $offsetmin, $length, $item{'TID'}, $item{'PID'}); 
    187168}else{ 
    188  
    189         $DBQuery =  "UPDATE  foltia_subtitle  SET  
    190         stationid = '$stationid', 
    191         countno = '$item{Count}', 
    192         subtitle = $programSubTitle , 
    193         startdatetime = '$recstartdate'  , 
    194         enddatetime = '$recenddate', 
    195         startoffset  = '$offsetmin' , 
    196         lengthmin = '$length'  
    197         WHERE tid = '$item{TID}' AND pid =  '$item{PID}' "; 
    198 
    199 #                $sth = $dbh->prepare($DBQuery); 
    200 #               $sth->execute(); 
    201         $oserr = $dbh->do($DBQuery); 
    202  
     169                $sth = $dbh->prepare($stmt{'getxml2db.7'}); 
     170                $oserr = $sth->execute($stationid, $item{'Count'}, $programSubTitle,  $recstartdate, $recenddate, $offsetmin, $length, $item{'TID'}, $item{'PID'}); 
     171            } 
    203172 }else{ 
    204173        #なければ追加 
     
    207176        #そのままキューに入る形で 
    208177        if ($item{Count} eq ""){ 
    209         $DBQuery = "insert into foltia_subtitle values ( '$item{PID}','$item{TID}','$stationid',null,$programSubTitle,'$recstartdate','$recenddate','$offsetmin' ,'$length')"; 
     178                $sth = $dbh->prepare($stmt{'getxml2db.8'}); 
     179                $oserr = $sth->execute($item{'PID'}, $item{'TID'}, $stationid, undef, $programSubTitle, $recstartdate, $recenddate, $offsetmin, $length); 
    210180        }else{ 
    211         $DBQuery = "insert into foltia_subtitle values ( '$item{PID}','$item{TID}','$stationid','$item{Count}',$programSubTitle,'$recstartdate','$recenddate','$offsetmin' ,'$length')"; 
     181                $sth = $dbh->prepare($stmt{'getxml2db.9'}); 
     182                $oserr = $sth->execute($item{'PID'}, $item{'TID'}, $stationid, $item{'Count'}, $programSubTitle, $recstartdate, $recenddate, $offsetmin, $length); 
    212183        } 
    213 #                $sth = $dbh->prepare($DBQuery); 
    214 #               $sth->execute(); 
    215         $oserr = $dbh->do($DBQuery); 
    216  
    217184} 
    218  
    219185 
    220186#print "$DBQuery\n\n\n"; 
     
    226192}#foreach 
    227193 
    228 #$oserr = $dbh->commit; 
     194$oserr = $dbh->commit; 
    229195##      $dbh->disconnect(); 
    230  
    231  
  • trunk/install/perl/ipodtranscode.pl

    r83 r94  
    1313use DBI; 
    1414use DBD::Pg; 
     15use DBD::SQLite; 
    1516use Jcode; 
    1617 
    1718$path = $0; 
    1819$path =~ s/ipodtranscode.pl$//i; 
    19 if ($pwd ne "./"){ 
     20if ($path ne "./"){ 
    2021push( @INC, "$path"); 
    2122} 
     
    3536 
    3637#DB初期化 
    37         my $data_source = sprintf("dbi:%s:dbname=%s;host=%s;port=%d", 
    38                 $DBDriv,$DBName,$DBHost,$DBPort); 
    39          $dbh = DBI->connect($data_source,$DBUser,$DBPass) ||die $DBI::error;; 
     38$dbh = DBI->connect($DSN,$DBUser,$DBPass) ||die $DBI::error;; 
    4039 
    4140# タイトル取得 
     
    5756 
    5857while ($counttranscodefiles >= 1){ 
    59  
    60 $DBQuery =  "SELECT foltia_subtitle.pid,foltia_subtitle.tid,foltia_subtitle.m2pfilename,filestatus,foltia_program.aspect ,foltia_subtitle.countno  
    61 FROM foltia_subtitle, foltia_program, foltia_m2pfiles  
    62 WHERE filestatus >= $FILESTATUSRECEND AND filestatus < $FILESTATUSTRANSCODECOMPLETE  AND foltia_program.tid = foltia_subtitle.TID AND foltia_program.PSP = 1  AND foltia_m2pfiles.m2pfilename = foltia_subtitle.m2pfilename  
    63 ORDER BY enddatetime ASC  
    64 LIMIT 1  "; 
    65  
    66 $sth = $dbh->prepare($DBQuery); 
    67 $sth->execute(); 
     58    $sth = $dbh->prepare($stmt{'ipodtranscode.1'}); 
     59    $sth->execute($FILESTATUSRECEND, $FILESTATUSTRANSCODECOMPLETE, ); 
    6860@dbparam = $sth->fetchrow_array; 
    6961#print "$dbparam[0],$dbparam[1],$dbparam[2],$dbparam[3],$dbparam[4],$dbparam[5]\n"; 
    70 &writelog("ipodtranscode DEBUG $DBQuery"); 
     62#&writelog("ipodtranscode DEBUG $DBQuery"); 
    7163&writelog("ipodtranscode DEBUG $dbparam[0],$dbparam[1],$dbparam[2],$dbparam[3],$dbparam[4],$dbparam[5]"); 
    7264$pid = $dbparam[0]; 
     
    8678# タイトル取得 
    8779if ($pid ne ""){ 
    88  
    89 $DBQuery =  "SELECT title , countno , subtitle   
    90 FROM  foltia_program, foltia_subtitle  
    91 WHERE foltia_program.tid = foltia_subtitle.tid  
    92 AND foltia_subtitle.pid = $pid "; 
    93 $sth = $dbh->prepare($DBQuery); 
    94 $sth->execute(); 
     80        $sth = $dbh->prepare($stmt{'ipodtranscode.2'}); 
     81        $sth->execute($pid); 
    9582@programtitle = $sth->fetchrow_array; 
    9683$programtitle[0] =~ s/\"/\\"/gi; 
     
    147134} 
    148135 
     136 
    149137$filenamebody = $inputmpeg2 ; 
    150138$filenamebody =~ s/.m2t$|.ts$|.m2p$|.mpg$//gi; 
     139 
    151140#デジタルかアナログか 
    152141if ($inputmpeg2 =~ /m2t$|ts$/i){ 
     
    174163        $ffmpegencopt = " -s 360x202 -deinterlace -r 24.00 -vcodec libx264 -g 300 -b 330000 -level 13 -loop 1 -sc_threshold 60 -partp4x4 1 -rc_eq 'blurCplx^(1-qComp)' -refs 3 -maxrate 700000 -async 50 -f h264 $filenamebody.264"; 
    175164        }elsif($trconqty == 2){ 
    176         $ffmpegencopt = " -s 480x272 -deinterlace -r 29.97 -vcodec libx264 -g 300 -b 400000 -level 13 -loop 1 -sc_threshold 60 -partp4x4 1 -rc_eq 'blurCplx^(1-qComp)' -refs 3 -maxrate 700000 -async 50 -f h264 $filenamebody.264"; 
     165#       $ffmpegencopt = " -s 480x272 -deinterlace -r 29.97 -vcodec libx264 -g 300 -b 400000 -level 13 -loop 1 -sc_threshold 60 -partp4x4 1 -rc_eq 'blurCplx^(1-qComp)' -refs 3 -maxrate 700000 -async 50 -f h264 $filenamebody.264"; 
     166# for ffmpeg 0.5 or later 
     167        $ffmpegencopt = " -s 480x272 -deinterlace -r 29.97 -vcodec libx264 -vpre default   -g 300 -b 400000 -level 13 -sc_threshold 60 -rc_eq 'blurCplx^(1-qComp)' -refs 3 -maxrate 700000 -async 50 -f h264 $filenamebody.264"; 
    177168        }elsif($trconqty == 3){#640x352 
    178         $ffmpegencopt = " -s 640x352 -deinterlace -r 29.97 -vcodec libx264 -g 100 -b 600000 -level 13 -loop 1 -sc_threshold 60 -partp4x4 1 -rc_eq 'blurCplx^(1-qComp)' -refs 3 -maxrate 700000 -async 50 -f h264 $filenamebody.264"; 
     169#       $ffmpegencopt = " -s 640x352 -deinterlace -r 29.97 -vcodec libx264 -g 100 -b 600000 -level 13 -loop 1 -sc_threshold 60 -partp4x4 1 -rc_eq 'blurCplx^(1-qComp)' -refs 3 -maxrate 700000 -async 50 -f h264 $filenamebody.264"; 
     170# for ffmpeg 0.5 or later 
     171        $ffmpegencopt = " -s 640x352 -deinterlace -r 29.97 -vcodec libx264 -vpre default   -g 100 -b 600000 -level 13 -sc_threshold 60 -rc_eq 'blurCplx^(1-qComp)' -refs 3 -maxrate 700000 -async 50 -f h264 $filenamebody.264"; 
    179172        } 
    180173        &changefilestatus($pid,$FILESTATUSTRANSCODEFFMPEG); 
     
    246239        # MP4ビルド 
    247240        unlink("${filenamebody}.base.mp4"); 
    248         &changefilestatus($pid,$FILESTATUSTRANSCODEMP4BOX); 
    249         &writelog("ipodtranscode MP4Box $filenamebody"); 
    250                 system ("cd $recfolderpath ; MP4Box -fps 29.97 -add $filenamebody.264 -new $filenamebody.base.mp4"); 
    251 #$exit_value = $? >> 8; 
    252 #$signal_num = $? & 127; 
    253 #$dumped_core = $? & 128;  
    254 #&writelog("ipodtranscode DEBUG MP4Box -fps 29.97 -add:$exit_value:$signal_num:$dumped_core"); 
    255  
    256         if (-e "$filenamebody.base.mp4"){ 
    257         system ("cd $recfolderpath ; MP4Box -add $filenamebody.aac $filenamebody.base.mp4"); 
    258 #$exit_value = $? >> 8; 
    259 #$signal_num = $? & 127; 
    260 #$dumped_core = $? & 128;  
    261 #&writelog("ipodtranscode DEBUG MP4Box -add $filenamebody.aac:$exit_value:$signal_num:$dumped_core"); 
     241        if (-e "$toolpath/perl/tool/MP4Box"){ 
     242                &changefilestatus($pid,$FILESTATUSTRANSCODEMP4BOX); 
     243                &writelog("ipodtranscode MP4Box $filenamebody"); 
     244#                       system ("cd $recfolderpath ; MP4Box -fps 29.97 -add $filenamebody.264 -new $filenamebody.base.mp4"); 
     245                        system ("cd $recfolderpath ;$toolpath/perl/tool/MP4Box -fps 29.97 -add $filenamebody.264 -new $filenamebody.base.mp4"); 
     246        $exit_value = $? >> 8; 
     247        $signal_num = $? & 127; 
     248        $dumped_core = $? & 128; 
     249        &writelog("ipodtranscode DEBUG MP4Box -fps 29.97 -add $filenamebody.264 -new $filenamebody.base.mp4:$exit_value:$signal_num:$dumped_core"); 
     250 
     251         
     252                if (-e "$filenamebody.base.mp4"){ 
     253#               system ("cd $recfolderpath ; MP4Box -add $filenamebody.aac $filenamebody.base.mp4"); 
     254                system ("cd $recfolderpath ;$toolpath/perl/tool/MP4Box -add $filenamebody.aac $filenamebody.base.mp4"); 
     255        $exit_value = $? >> 8; 
     256        $signal_num = $? & 127; 
     257        $dumped_core = $? & 128;  
     258        &writelog("ipodtranscode DEBUG MP4Box -add $filenamebody.aac:$exit_value:$signal_num:$dumped_core"); 
     259                }else{ 
     260                $filelist = `ls -lhtr $recfolderpath/${filenamebody}*`; 
     261                $debugenv = `env`; 
     262                &writelog("ipodtranscode ERR File not exist.$debugenv.$filelist ;$filenamebody.base.mp4;$filelist;cd $recfolderpath ;$toolpath/perl/tool/MP4Box -fps 29.97 -add $filenamebody.264 -new $filenamebody.base.mp4"); 
     263                } 
    262264        }else{ 
    263         &writelog("ipodtranscode ERR File not exist.$filenamebody.base.mp4"); 
    264         } 
    265  
    266 
    267  
    268 if ($filestatus <= $FILESTATUSTRANSCODEATOM){ 
    269         unlink("${mp4outdir}MAQ${mp4filenamestring}.MP4"); 
    270         # iPodヘッダ付加 
    271         &changefilestatus($pid,$FILESTATUSTRANSCODEATOM); 
    272         &writelog("ipodtranscode ATOM $filenamebody"); 
    273         #system ("/usr/local/bin/ffmpeg -y -i $filenamebody.base.mp4 -vcodec copy -acodec copy -f ipod ${mp4outdir}MAQ${mp4filenamestring}.MP4"); 
    274         system ("cd $recfolderpath ; MP4Box -ipod $filenamebody.base.mp4"); 
    275 $exit_value = $? >> 8; 
    276 $signal_num = $? & 127; 
    277 $dumped_core = $? & 128; 
    278 &writelog("ipodtranscode DEBUG MP4Box -ipod:$exit_value:$signal_num:$dumped_core"); 
    279         system("mv $filenamebody.base.mp4 ${mp4outdir}MAQ${mp4filenamestring}.MP4"); 
    280         &writelog("ipodtranscode mv $filenamebody.base.mp4 ${mp4outdir}MAQ${mp4filenamestring}.MP4"); 
    281 # ipodtranscode mv /home/foltia/php/tv/1329-21-20080829-0017.base.mp4 /home/foltia/php/tv/1329.localized/mp4/MAQ-/home/foltia/php/tv/1329-21-20080829-0017.MP4 
    282  
     265                &writelog("ipodtranscode WARN; Pls. install $toolpath/perl/tool/MP4Box"); 
     266        } 
     267#} 
     268 
     269#if ($filestatus <= $FILESTATUSTRANSCODEATOM){ 
     270        if (-e "$toolpath/perl/tool/MP4Box"){ 
     271                # iPodヘッダ付加 
     272#               &changefilestatus($pid,$FILESTATUSTRANSCODEATOM); 
     273                &writelog("ipodtranscode ATOM $filenamebody"); 
     274                #system ("/usr/local/bin/ffmpeg -y -i $filenamebody.base.mp4 -vcodec copy -acodec copy -f ipod ${mp4outdir}MAQ${mp4filenamestring}.MP4"); 
     275#               system ("cd $recfolderpath ; MP4Box -ipod $filenamebody.base.mp4"); 
     276                system ("cd $recfolderpath ; $toolpath/perl/tool/MP4Box -ipod $filenamebody.base.mp4"); 
     277        $exit_value = $? >> 8; 
     278        $signal_num = $? & 127; 
     279        $dumped_core = $? & 128; 
     280        &writelog("ipodtranscode DEBUG MP4Box -ipod $filenamebody.base.mp4:$exit_value:$signal_num:$dumped_core"); 
     281                if (-e "$filenamebody.base.mp4"){ 
     282                unlink("${mp4outdir}MAQ${mp4filenamestring}.MP4"); 
     283                system("mv $filenamebody.base.mp4 ${mp4outdir}MAQ${mp4filenamestring}.MP4"); 
     284                &writelog("ipodtranscode mv $filenamebody.base.mp4 ${mp4outdir}MAQ${mp4filenamestring}.MP4"); 
     285                }else{ 
     286                &writelog("ipodtranscode ERR $filenamebody.base.mp4 Not found."); 
     287                } 
     288        # ipodtranscode mv /home/foltia/php/tv/1329-21-20080829-0017.base.mp4 /home/foltia/php/tv/1329.localized/mp4/MAQ-/home/foltia/php/tv/1329-21-20080829-0017.MP4 
     289        }else{ 
     290                &writelog("ipodtranscode WARN; Pls. install $toolpath/perl/tool/MP4Box"); 
     291        } 
    283292} 
    284293if ($filestatus <= $FILESTATUSTRANSCODECOMPLETE){ 
     294        if (-e "${mp4outdir}MAQ${mp4filenamestring}.MP4"){ 
    285295        # 中間ファイル消す 
    286296        &changefilestatus($pid,$FILESTATUSTRANSCODECOMPLETE); 
     
    293303         
    294304        &updatemp4file(); 
    295  
     305        }else{ 
     306                &writelog("ipodtranscode ERR ; Fail MAQ${mp4filenamestring}.MP4"); 
     307        } 
    296308} 
    297309 
     
    384396&writelog("ipodtranscode DEBUG thmfilename $thmfilename"); 
    385397 
    386 system ("mplayer -ss 00:01:20 -vo jpeg:outdir=$pspdirname -ao null -sstep 1 -frames 3  -v 3 $outputfilename"); 
    387  
    388 &writelog("ipodtranscode DEBUG mplayer -ss 00:01:20 -vo jpeg:outdir=$pspdirname -ao null -sstep 1 -frames 3  -v 3 $outputfilename"); 
    389  
    390 if (-e "$pspdirname/$thmfilename"){ 
    391 $timestamp =`date "+%Y%m%d-%H%M%S"`; 
    392 chomp $timestamp; 
    393         system("convert -crop 160x120+1+3 -resize 165x126\! $pspdirname/00000002.jpg $pspdirname/$thmfilename".$timestamp.".THM"); 
     398#system ("mplayer -ss 00:01:20 -vo jpeg:outdir=$pspdirname -ao null -sstep 1 -frames 3  -v 3 $outputfilename"); 
     399
     400#&writelog("ipodtranscode DEBUG mplayer -ss 00:01:20 -vo jpeg:outdir=$pspdirname -ao null -sstep 1 -frames 3  -v 3 $outputfilename"); 
     401if($outputfilename =~ /.m2t$/){ 
     402#ハイビジョンTS 
     403system ("mplayer -ss 00:01:20 -vo jpeg:outdir=$pspdirname -ao null -vf framestep=300step,scale=160:90,expand=160:120 -frames 1 $outputfilename"); 
     404&writelog("ipodtranscode DEBUG mplayer -ss 00:01:20 -vo jpeg:outdir=$pspdirname -ao null -vf framestep=300step,scale=160:90,expand=160:120 -frames 1 $outputfilename"); 
    394405}else{ 
    395         system("convert -crop 160x120+1+3 -resize 165x126\! $pspdirname/00000002.jpg $pspdirname/$thmfilename"); 
    396 
    397 &writelog("ipodtranscode DEBUG convert -crop 160x120+1+3 -resize 165x126\! $pspdirname/00000002.jpg $pspdirname/$thmfilename"); 
    398  
    399 system("rm -rf $pspdirname/0000000*.jpg "); 
    400 &writelog("ipodtranscode DEBUG rm -rf $pspdirname/0000000*.jpg"); 
     406#アナログ 
     407system ("mplayer -ss 00:01:20 -vo jpeg:outdir=$pspdirname -ao null -vf framestep=300step,scale=165:126,crop=160:120 -frames 1 $outputfilename"); 
     408&writelog("ipodtranscode DEBUG mplayer -ss 00:01:20 -vo jpeg:outdir=$pspdirname -ao null -vf framestep=300step,scale=165:126,crop=160:120 -frames 1 $outputfilename"); 
     409
     410#if (-e "$pspdirname/$thmfilename"){ 
     411#       $timestamp = strftime("%Y%m%d-%H%M%S", localtime); 
     412#chomp $timestamp; 
     413#       system("convert -crop 160x120+1+3 -resize 165x126\! $pspdirname/00000002.jpg $pspdirname/$thmfilename".$timestamp.".THM"); 
     414#}else{ 
     415#       system("convert -crop 160x120+1+3 -resize 165x126\! $pspdirname/00000002.jpg $pspdirname/$thmfilename"); 
     416#} 
     417#&writelog("ipodtranscode DEBUG convert -crop 160x120+1+3 -resize 165x126\! $pspdirname/00000002.jpg $pspdirname/$thmfilename"); 
     418 
     419#system("rm -rf $pspdirname/0000000*.jpg "); 
     420#&writelog("ipodtranscode DEBUG rm -rf $pspdirname/0000000*.jpg"); 
     421system("mv $pspdirname/00000001.jpg $pspdirname/$thmfilename"); 
    401422 
    402423}#endsub makethumbnail 
     
    407428if (-e "${mp4outdir}MAQ${mp4filenamestring}.MP4"){ 
    408429# MP4ファイル名をPIDレコードに書き込み 
    409         $DBQuery =  "UPDATE foltia_subtitle SET PSPfilename = '$mp4filename' WHERE pid = '$pid' "; 
    410          $sth = $dbh->prepare($DBQuery); 
    411         $sth->execute(); 
    412 &writelog("ipodtranscode UPDATEsubtitleDB $DBQuery"); 
     430        $sth = $dbh->prepare($stmt{'ipodtranscode.updatemp4file.1'}); 
     431        $sth->execute($mp4filename, $pid); 
     432        &writelog("ipodtranscode UPDATEsubtitleDB $stmt{'ipodtranscode.updatemp4file.1'}"); 
    413433 
    414434# MP4ファイル名をfoltia_mp4files挿入 
    415         $DBQuery = "insert into foltia_mp4files values ('$tid','$mp4filename') "; 
    416          $sth = $dbh->prepare($DBQuery); 
    417         $sth->execute(); 
    418 &writelog("ipodtranscode UPDATEmp4DB $DBQuery"); 
     435        $sth = $dbh->prepare($stmt{'ipodtranscode.updatemp4file.2'}); 
     436        $sth->execute($tid, $mp4filename); 
     437        &writelog("ipodtranscode UPDATEmp4DB $stmt{'ipodtranscode.updatemp4file.2'}"); 
    419438 
    420439&changefilestatus($pid,$FILESTATUSALLCOMPLETE); 
     
    427446 
    428447sub counttranscodefiles(){ 
    429 my $DBQuery =  "SELECT count(*) FROM foltia_subtitle, foltia_program, foltia_m2pfiles  
    430 WHERE filestatus >= $FILESTATUSRECEND AND filestatus < $FILESTATUSTRANSCODECOMPLETE  AND foltia_program.tid = foltia_subtitle.TID AND foltia_program.PSP = 1  AND foltia_m2pfiles.m2pfilename = foltia_subtitle.m2pfilename  "; 
    431 $sth = $dbh->prepare($DBQuery); 
    432 $sth->execute(); 
     448    $sth = $dbh->prepare($stmt{'ipodtranscode.counttranscodefiles.1'}); 
     449    $sth->execute($FILESTATUSRECEND, $FILESTATUSTRANSCODECOMPLETE); 
    433450my @titlecount= $sth->fetchrow_array; 
    434451 
  • trunk/install/perl/mklocalizeddir.pl

    r1 r94  
    1616use DBI; 
    1717use DBD::Pg; 
    18  
     18use DBD::SQLite; 
    1919 
    2020$path = $0; 
    2121$path =~ s/mklocalizeddir.pl$//i; 
    22 if ($pwd ne "./"){ 
     22if ($path ne "./"){ 
    2323push( @INC, "$path"); 
    2424} 
     
    4343 
    4444#接続 
    45         my $data_source = sprintf("dbi:%s:dbname=%s;host=%s;port=%d", 
    46                 $DBDriv,$DBName,$DBHost,$DBPort); 
    47          $dbh = DBI->connect($data_source,$DBUser,$DBPass) ||die $DBI::error;; 
     45    $dbh = DBI->connect($DSN,$DBUser,$DBPass) ||die $DBI::error;; 
    4846 
    4947#検索 
    50 $DBQuery =  "select title from foltia_program where tid=$tid "; 
    51          $sth = $dbh->prepare($DBQuery); 
    52         $sth->execute(); 
     48    $sth = $dbh->prepare($stmt{'mklocalizeddir.1'}); 
     49    $sth->execute($tid); 
    5350 @subticount= $sth->fetchrow_array; 
    5451$title = $subticount[0] ; 
  • trunk/install/perl/recwrap.pl

    r91 r94  
    1515use DBI; 
    1616use DBD::Pg; 
     17use DBD::SQLite; 
    1718use Schedule::At; 
    1819use Time::Local; 
     
    2122$path = $0; 
    2223$path =~ s/recwrap.pl$//i; 
    23 if ($pwd ne "./"){ 
     24if ($path ne "./"){ 
    2425push( @INC, "$path"); 
    2526} 
     
    4647 
    4748#DB初期化 
    48         my $data_source = sprintf("dbi:%s:dbname=%s;host=%s;port=%d", 
    49                 $DBDriv,$DBName,$DBHost,$DBPort); 
    50          $dbh = DBI->connect($data_source,$DBUser,$DBPass) ||die $DBI::error;; 
     49$dbh = DBI->connect($DSN,$DBUser,$DBPass) ||die $DBI::error;; 
    5150 
    5251 
     
    5756} 
    5857 
    59 $outputfile = `date  +%Y%m%d-%H%M --date "1 min "`
     58$outputfile = strftime("%Y%m%d-%H%M", localtime(time + 60))
    6059chomp($outputfile); 
    6160 
     
    7776&writelog("recwrap RECSTART DIGITAL $digitalstationband $digitalch $reclength $stationid 0 $outputfilename $tid $countno friio"); 
    7877#録画 
    79 $starttime = (`date +%s`); 
     78    $starttime = time(); 
    8079$oserr = system("$toolpath/perl/digitaltvrecording.pl $digitalstationband $digitalch $reclength $stationid 0 $outputfilename $tid $countno friio"); 
    8180$oserr = $oserr / 256; 
     
    119118#録画 
    120119#system("$toolpath/perl/tvrecording.pl $recch $reclength 0 $outputfile $bitrate $tid $countno"); 
    121 $starttime = (`date +%s`); 
     120    $starttime = time(); 
    122121 
    123122$oserr = system("$toolpath/perl/tvrecording.pl $recch $reclength 0 $outputfilename $bitrate $tid $countno"); 
     
    131130 
    132131#デバイスビジーで即死してないか検出 
    133 $now = (`date +%s`); 
     132$now = time(); 
    134133        if ($now < $starttime + 100){ #録画プロセス起動してから100秒以内に戻ってきてたら 
    135        $retrycounter == 0; 
     134    $retrycounter = 0; 
    136135                while($now < $starttime + 100){ 
    137136                        if($retrycounter >= 5){ 
     
    141140                &writelog("recwrap retry recording $now $starttime"); 
    142141                #アナログ録画 
    143 $starttime = (`date +%s`); 
     142       $starttime = time(); 
    144143if($outputfilename =~ /.m2t$/){ 
    145144        $outputfilename =~ s/.m2t$/.m2p/; 
    146145} 
    147146$oserr = system("$toolpath/perl/tvrecording.pl $recch $reclength N $outputfilename $bitrate $tid $countno"); 
    148 $now = (`date +%s`); 
     147       $now = time(); 
    149148$oserr = $oserr / 256; 
    150149                        if ($oserr == 1){ 
     
    160159 
    161160# m2pファイル名をPIDレコードに書き込み 
    162         $DBQuery =  "UPDATE foltia_subtitle SET m2pfilename = '$outputfilename' WHERE pid = '$pid' "; 
    163          $sth = $dbh->prepare($DBQuery); 
    164         $sth->execute(); 
    165 &writelog("recwrap DEBUG UPDATEDB $DBQuery"); 
     161$sth = $dbh->prepare($stmt{'recwrap.1'}); 
     162$sth->execute($outputfilename, $pid); 
     163&writelog("recwrap DEBUG UPDATEDB $stmt{'recwrap.1'}"); 
    166164&changefilestatus($pid,$FILESTATUSRECEND); 
    167165 
    168166# m2pファイル名をPIDレコードに書き込み 
    169         $DBQuery =  "insert into foltia_m2pfiles values ('$outputfilename')"; 
    170          $sth = $dbh->prepare($DBQuery); 
    171         $sth->execute(); 
    172 &writelog("recwrap DEBUG UPDATEDB $DBQuery"); 
     167$sth = $dbh->prepare($stmt{'recwrap.2'}); 
     168$sth->execute($outputfilename); 
     169&writelog("recwrap DEBUG UPDATEDB $stmt{'recwrap.2'}"); 
    173170 
    174171# Starlight breaker向けキャプチャ画像作成 
     
    181178 
    182179 
    183  
    184180# MPEG4 ------------------------------------------------------ 
    185181#MPEG4トラコン必要かどうか 
    186 $DBQuery =  "SELECT psp,aspect,title FROM foltia_program WHERE tid = '$tid' "; 
    187          $sth = $dbh->prepare($DBQuery); 
    188         $sth->execute(); 
     182$sth = $dbh->prepare($stmt{'recwrap.3'}); 
     183$sth->execute($tid); 
    189184 @psptrcn= $sth->fetchrow_array; 
    190185if ($psptrcn[0]  == 1 ){#トラコン番組 
     
    192187exec ("$toolpath/perl/ipodtranscode.pl"); 
    193188exit; 
    194 # 
    195 # ここから下は旧エンコード#2008/12/23  
    196 # 新エンコードはDBを見て未完了MPEG2を順次トラコン処理、 
    197 # 分散エンコードもきっとラクチンに対応可能 
    198 # 新エンコードではXviD/M4VスタイルとPSPファイル名対応を廃止 
    199  
    200 &changefilestatus($pid,80); 
    201 #MPEG4ムービーディレクトリがあるかどうか 
    202   
    203 #TIDが100以上の3桁の場合はそのまま 
    204 my $pspfilnamehd = ""; 
    205  
    206 $pspfilnamehd = $tid; 
    207 &makemp4dir($tid); 
    208 $pspdirname = "$tid.localized/"; 
    209 $pspdirname = $recfolderpath."/".$pspdirname; 
    210  
    211 #なければ作る 
    212 #unless (-e $pspdirname ){ 
    213 #       system("$toolpath/perl/mklocalizeddir.pl $tid"); 
    214 #       #&writelog("recwrap mkdir $pspdirname"); 
    215 #} 
    216 $pspdirname = "$tid.localized/mp4/"; 
    217 $pspdirname = $recfolderpath."/".$pspdirname; 
    218 #なければ作る 
    219 #unless (-e $pspdirname ){ 
    220 #       mkdir $pspdirname ,0777; 
    221 #       #&writelog("recwrap mkdir $pspdirname"); 
    222 #} 
    223  
    224 #ファイル名決定 
    225 if ($mp4filenamestyle == 1){# 1;よりわかりやすいファイル名 
    226  $pspfilname = $mp4newstylefilename ; 
    227   
    228 }else{##0:PSP ファームウェアver.2.80より前と互換性を持つファイル名 
    229 #・フォルダ名[100MNV01]の100の部分は変更可(100〜999)。 
    230 # MP_ROOT ━ 100MNV01 ┳ M4V00001.MP4(動画) 
    231 #┃                  ┗ M4V00001.THM(サムネイル)※必須ではない 
    232  
    233 #ファイル名決定 
    234 #ファイル名決定 #新アルゴリズム 
    235 #TID 0000-3599まで[3桁] 
    236 #話数 00-999まで[2桁] 
    237  
    238 my $pspfilnameft = ""; 
    239 my $pspfilnameyearhd = ""; 
    240 my $pspfilnameyearft = ""; 
    241  
    242 $btid = $tid % 3600; 
    243 # print "$btid\n"; 
    244  
    245 if($btid >= 0 && $btid < 1000){ 
    246  
    247         $pspfilnamehd = sprintf("%03d",$btid); 
    248  
    249 }elsif ($btid >= 1000 && $btid < 3600){ 
    250         $pspfilnameyearhd = substr($btid, 0, 2); 
    251         $pspfilnameyearhd =~ s/10/A/; 
    252         $pspfilnameyearhd =~ s/11/B/; 
    253         $pspfilnameyearhd =~ s/12/C/; 
    254         $pspfilnameyearhd =~ s/13/D/; 
    255         $pspfilnameyearhd =~ s/14/E/; 
    256         $pspfilnameyearhd =~ s/15/F/; 
    257         $pspfilnameyearhd =~ s/16/G/; 
    258         $pspfilnameyearhd =~ s/17/H/; 
    259         $pspfilnameyearhd =~ s/18/I/; 
    260         $pspfilnameyearhd =~ s/19/J/; 
    261         $pspfilnameyearhd =~ s/20/K/; 
    262         $pspfilnameyearhd =~ s/21/L/; 
    263         $pspfilnameyearhd =~ s/22/M/; 
    264         $pspfilnameyearhd =~ s/23/N/; 
    265         $pspfilnameyearhd =~ s/24/O/; 
    266         $pspfilnameyearhd =~ s/25/P/; 
    267         $pspfilnameyearhd =~ s/26/Q/; 
    268         $pspfilnameyearhd =~ s/27/R/; 
    269         $pspfilnameyearhd =~ s/28/S/; 
    270         $pspfilnameyearhd =~ s/29/T/; 
    271         $pspfilnameyearhd =~ s/30/U/; 
    272         $pspfilnameyearhd =~ s/31/V/; 
    273         $pspfilnameyearhd =~ s/32/W/; 
    274         $pspfilnameyearhd =~ s/33/X/; 
    275         $pspfilnameyearhd =~ s/34/Y/; 
    276         $pspfilnameyearhd =~ s/35/Z/; 
    277          
    278 $pspfilnameyearft = substr($btid, 2, 2); 
    279 $pspfilnameyearft = sprintf("%02d",$pspfilnameyearft); 
    280 $pspfilnamehd = $pspfilnameyearhd . $pspfilnameyearft; 
    281  
    282 } 
    283  
    284 # 話数 
    285 if (0 < $countno && $countno < 100 ){ 
    286 # 2桁 
    287         $pspfilnameft = sprintf("%02d",$countno); 
    288 }elsif(100 <= $countno && $countno < 1000 ){ 
    289 # 3桁 
    290         $pspfilnameft = sprintf("%03d",$countno); # 話数3桁 
    291         $pspfilnamehd = substr($pspfilnamehd, 0, 2); # TID 二桁 後ろ1バイト落とし 
    292 }elsif(1000 <= $countno && $countno < 10000 ){ 
    293 # 4桁 
    294         $pspfilnameft = sprintf("%04d",$countno); # 話数4桁 
    295         $pspfilnamehd = substr($pspfilnamehd, 0, 1); # TID 1桁 後ろ2バイト落とし 
    296  
    297  
    298 }elsif($countno == 0){ 
    299 #タイムスタンプが最新のMP4ファイル名取得 
    300 my $newestmp4filename = `cd $pspdirname ; ls -t *.MP4 | head -1`; 
    301  if ($newestmp4filename =~ /M4V$tid/){ 
    302         $nowcountno = $' ; 
    303                 $nowcountno++; 
    304                 $pspfilnameft = sprintf("%02d",$nowcountno); 
    305         while (-e "$pspdirname/M4V".$pspfilnamehd.$pspfilnameft.".MP4"){ 
    306                 $nowcountno++; 
    307                 $pspfilnameft = sprintf("%02d",$nowcountno);     
    308         print "File exist:$nowcountno\n"; 
    309         } 
    310 #print "NeXT\n"; 
    311 }else{ 
    312 # 0の場合 週番号を100から引いたもの 
    313 # week number of year with Monday as first day of week (01..53) 
    314 #だったけど常に0に 
    315 #       my $weeno = `date "+%V"`; 
    316 #       $weeno = 100 - $weeno ; 
    317 #       $pspfilnameft = sprintf("%02d",$weeno); 
    318         $pspfilnameft = sprintf("%02d",0); 
    319 #print "WEEKNO\n"; 
    320 } 
    321  
    322 } 
    323  
    324 my $pspfilname = $pspfilnamehd.$pspfilnameft  ; 
    325 # print "$pspfilname($pspfilnamehd/$pspfilnameft)\n"; 
    326 }# endif MP4ファイル名が新styleなら 
    327 #2006/12/03_10:30:24 recwrap TRCNSTART vfr4psp.sh /home/foltia/php/tv/591-87-20061203-1000.m2p -591-87-20061203-1000 /home/foltia/php/tv/591.localized/mp4/ 3 
    328  
    329  
    330 # トラコンキューイング #2007/7/10  
    331 my $trcnprocesses = ""; 
    332 my $cpucores = `ls /proc/acpi/processor | wc -l`; 
    333 $cpucores =~ s/[^0-9]//gi; 
    334 unless ($cpucores >= 1 ){ 
    335         $cpucores = 1; 
    336 } 
    337 do { 
    338         $trcnprocesses = `ps ax | grep ffmpeg | grep -v grep |  wc -l `; 
    339         $trcnprocesses =~ s/[^0-9]//gi; 
    340         # 既にトラコンプロセスが走っているなら適当に待機 
    341         if ($trcnprocesses  >= $cpucores){ 
    342                         if (-e "/proc/uptime" ){ 
    343                         $loadaverage = `uptime`; 
    344                         chomp($loadaverage); 
    345                         }else{ 
    346                         $loadaverage = ""; 
    347                         } 
    348                         &writelog("recwrap TRCN WAITING :$trcnprocesses / $cpucores :$outputfilename $loadaverage"); 
    349                 sleep 113; 
    350                 sleep ($recch)*5; 
    351         } 
    352 } until ($trcnprocesses  < $cpucores); 
    353  
    354  
    355 if (($trconqty eq "")||($trconqty == 0 )){ 
    356         &writelog("recwrap TRCNSTART vfr4psp.sh $recfolderpath/$outputfilename $pspfilname $pspdirname $psptrcn[1]"); 
    357         system("$toolpath/perl/transcode/vfr4psp.sh $recfolderpath/$outputfilename $pspfilname $pspdirname $psptrcn[1]"); 
    358         &writelog("recwrap TRCNEND  vfr4psp.sh $recfolderpath/$outputfilename $pspfilname $pspdirname $psptrcn[1]"); 
    359         #最適化 
    360         $DBQuery =  "SELECT subtitle  FROM  foltia_subtitle WHERE tid = '$tid' AND countno = '$countno' "; 
    361                  $sth = $dbh->prepare($DBQuery); 
    362                 $sth->execute(); 
    363          @programtitle = $sth->fetchrow_array; 
    364         if ( $countno == "0" ){ 
    365                 $pspcountno = ""; 
    366         }else{ 
    367                 $pspcountno = $countno ; 
    368         } 
    369         &writelog("recwrap OPTIMIZE  mp4psp -p $pspdirname/M4V$pspfilname.MP4   -t  '$psptrcn[2] $pspcountno $programtitle[0]' "); 
    370         Jcode::convert(\$programtitle[0],'euc'); 
    371         system ("/usr/local/bin/mp4psp -p $pspdirname/M4V$pspfilname.MP4   -t  '$psptrcn[2] $pspcountno $programtitle[0]'") ; 
    372 $mp4filename = "M4V${pspfilname}.MP4"; 
    373 $thmfilename = "M4V${pspfilname}.THM"; 
    374 }else{# #2006/12/6 新エンコーダ 
    375  
    376         &writelog("recwrap TRCNSTART ipodtranscode.pl $recfolderpath/$outputfilename $pspfilname $pspdirname $pid $psptrcn[1]"); 
    377         system("$toolpath/perl/ipodtranscode.pl $recfolderpath/$outputfilename $pspfilname $pspdirname $pid $psptrcn[1]"); 
    378         &writelog("recwrap TRCNEND  ipodtranscode.pl $recfolderpath/$outputfilename $pspfilname $pspdirname $psptrcn[1]"); 
    379  
    380         if($trconqty >= 2){#H.264/AVCなら 
    381         $mp4filename = "MAQ${pspfilname}.MP4"; 
    382         $thmfilename = "MAQ${pspfilname}.THM"; 
    383         }else{ 
    384         $mp4filename = "M4V${pspfilname}.MP4"; 
    385         $thmfilename = "M4V${pspfilname}.THM"; 
    386         } 
    387 } 
    388  
    389 #サムネール 
    390  
    391 # mplayer -ss 00:01:20 -vo jpeg:outdir=/home/foltia/php/tv/443MNV01 -ao null -sstep 1 -frames 3  -v 3 /home/foltia/php/tv/443-07-20050218-0030.m2p 
    392 #2005/02/22_18:30:05 recwrap TRCNSTART vfr4psp.sh /home/foltia/php/tv/447-21-20050222-1800.m2p 44721 /home/foltia/php/tv/447MNV01 3 
    393 &writelog("recwrap THAMJ  mplayer -ss 00:01:20 -vo jpeg:outdir=$pspdirname -ao null -sstep 1 -frames 3  -v 3 $recfolderpath/$outputfilename "); 
    394 system ("mplayer -ss 00:01:20 -vo jpeg:outdir=$pspdirname -ao null -sstep 1 -frames 3  -v 3 $recfolderpath/$outputfilename"); 
    395 &writelog("recwrap THAMI  convert -crop 160x120+1+3 -resize 165x126\! $pspdirname/00000002.jpg $pspdirname/M4V$pspdirname.THM "); 
    396  
    397 if (-e "$pspdirname/$thmfilename"){ 
    398 $timestamp =`date "+%Y%m%d-%H%M%S"`; 
    399 chomp $timestamp; 
    400         system("convert -crop 160x120+1+3 -resize 165x126\! $pspdirname/00000002.jpg $pspdirname/$thmfilename".$timestamp.".THM"); 
    401  
    402 }else{ 
    403         system("convert -crop 160x120+1+3 -resize 165x126\! $pspdirname/00000002.jpg $pspdirname/$thmfilename"); 
    404 } 
    405 # rm -rf 00000001.jpg       
    406 # convert -resize 160x120\! 00000002.jpg M4V44307.THM 
    407 # rm -rf 00000002.jpg   
    408 system("rm -rf $pspdirname/0000000*.jpg "); 
    409  
    410  
    411  
    412  
    413 # MP4ファイル名をPIDレコードに書き込み 
    414         $DBQuery =  "UPDATE foltia_subtitle SET PSPfilename = '$mp4filename' WHERE pid = '$pid' "; 
    415          $sth = $dbh->prepare($DBQuery); 
    416         $sth->execute(); 
    417 &writelog("recwrap UPDATEsubtitleDB  $DBQuery"); 
    418  
    419 # MP4ファイル名をfoltia_mp4files挿入 
    420         $DBQuery = "insert into foltia_mp4files values ('$tid','$mp4filename') "; 
    421          $sth = $dbh->prepare($DBQuery); 
    422         $sth->execute(); 
    423 &writelog("recwrap UPDATEmp4DB  $DBQuery"); 
    424  
    425 &changefilestatus($pid,200); 
    426189}#PSPトラコンあり 
    427190 
    428191sub continuousrecordingcheck(){ 
    429 my $now = `date  +%s --date "2 min "`
     192    my $now = time() + 60 * 2
    430193&writelog("recwrap DEBUG continuousrecordingcheck() now $now"); 
    431194my @processes =`ps ax | grep recfriio`; 
     
    474237                $startdatetime = $startdate.$filenameparts[0]; 
    475238                #DBから録画中番組のデータ探す 
    476         $DBQuery =  " 
    477 SELECT foltia_subtitle.tid,foltia_subtitle.countno,foltia_subtitle.subtitle,foltia_subtitle.startdatetime ,foltia_subtitle.enddatetime ,foltia_subtitle.lengthmin ,foltia_tvrecord.bitrate , foltia_subtitle.startoffset , foltia_subtitle.pid ,foltia_tvrecord.digital  
    478 FROM foltia_subtitle ,foltia_tvrecord  
    479 WHERE  
    480 foltia_tvrecord.tid = foltia_subtitle.tid AND  
    481 foltia_tvrecord.tid = $tid AND  
    482 foltia_subtitle.startdatetime = $startdatetime AND  
    483 foltia_tvrecord.digital = 1"; 
    484         &writelog("recwrap DEBUG continuousrecordingcheck() $DBQuery"); 
    485         $sth = $dbh->prepare($DBQuery); 
     239                    &writelog("recwrap DEBUG continuousrecordingcheck() $stmt{'recwrap.7'}"); 
     240                    $sth = $dbh->prepare($stmt{'recwrap.7'}); 
    486241        &writelog("recwrap DEBUG continuousrecordingcheck() prepare"); 
    487         $sth->execute(); 
     242                   $sth->execute($tid, $startdatetime); 
    488243        &writelog("recwrap DEBUG continuousrecordingcheck() execute"); 
    489244        @recfile = $sth->fetchrow_array; 
  • trunk/install/perl/schedulecheck.pl

    r1 r94  
    1414use DBI; 
    1515use DBD::Pg; 
     16use DBD::SQLite; 
    1617use Schedule::At; 
    1718use Time::Local; 
     
    1920$path = $0; 
    2021$path =~ s/schedulecheck.pl$//i; 
    21 if ($pwd ne "./"){ 
     22if ($path ne "./"){ 
    2223push( @INC, "$path"); 
    2324} 
     
    2930 
    3031#予約番組探し 
    31 $now = &epoch2foldate(`date +%s`); 
     32$now = &epoch2foldate(time()); 
    3233$now = &epoch2foldate($now); 
    3334$checkrangetime = $now   + 15*60;#15分後まで 
    3435$checkrangetime =  &epoch2foldate($checkrangetime); 
    3536 
    36         my $data_source = sprintf("dbi:%s:dbname=%s;host=%s;port=%d", 
    37                 $DBDriv,$DBName,$DBHost,$DBPort); 
    38          $dbh = DBI->connect($data_source,$DBUser,$DBPass) ||die $DBI::error;; 
     37$dbh = DBI->connect($DSN,$DBUser,$DBPass) ||die $DBI::error;; 
    3938 
    40 $DBQuery =  "SELECT count(*)  FROM foltia_tvrecord "; 
    41  
    42  
    43          $sth = $dbh->prepare($DBQuery); 
     39$sth = $dbh->prepare($stmt{'schedulecheck.1'}); 
    4440        $sth->execute(); 
    4541 @titlecount= $sth->fetchrow_array; 
     
    4844exit; 
    4945}else{ 
    50  
    51 $DBQuery =  "SELECT  tid ,stationid  FROM foltia_tvrecord "; 
    52          $sth = $dbh->prepare($DBQuery); 
     46    $sth = $dbh->prepare($stmt{'schedulecheck.2'}); 
    5347        $sth->execute(); 
    5448while (($tid,$stationid  ) = $sth->fetchrow_array()) { 
  • trunk/install/perl/singletranscode.pl

    r1 r94  
    2828use DBI; 
    2929use DBD::Pg; 
     30use DBD::SQLite; 
    3031use Schedule::At; 
    3132use Time::Local; 
     
    3435$path = $0; 
    3536$path =~ s/singletranscode.pl$//i; 
    36 if ($pwd ne "./"){ 
     37if ($path ne "./"){ 
    3738push( @INC, "$path"); 
    3839} 
     
    6364 
    6465#PSPトラコン必要かどうか 
    65         my $data_source = sprintf("dbi:%s:dbname=%s;host=%s;port=%d", 
    66  
    67                 $DBDriv,$DBName,$DBHost,$DBPort); 
    68          $dbh = DBI->connect($data_source,$DBUser,$DBPass) ||die $DBI::error;; 
     66$dbh = DBI->connect($DSN,$DBUser,$DBPass) ||die $DBI::error;; 
    6967 
    7068if ($ARGV[1] != ""){ 
    7169        $pid = $ARGV[1] ; 
    7270}else{ 
    73 $DBQuery =  "SELECT pid FROM  foltia_subtitle WHERE m2pfilename = '$ARGV[0]' "; 
    74          $sth = $dbh->prepare($DBQuery); 
    75         $sth->execute(); 
     71    $sth = $dbh->prepare($stmt{'singletranscode.1'}); 
     72    $sth->execute($ARGV[0]); 
    7673 @pidarray = $sth->fetchrow_array; 
    7774        unless ($pidarray[0]  == "" ){ 
     
    8683# 追加部分 
    8784 
    88 $query =  "SELECT count(*)  FROM  foltia_subtitle WHERE tid = '$tid' AND countno = '$countno' "; 
    89          $sth = $dbh->prepare($query); 
    90         $sth->execute(); 
     85$sth = $dbh->prepare($stmt{'singletranscode.2'}); 
     86$sth->execute($tid, $countno); 
    9187 @subticount= $sth->fetchrow_array; 
    9288 unless ($subticount[0]  >= 1){ 
    9389 
    94 $query =  "SELECT count(*)  FROM  foltia_subtitle WHERE tid = '$tid'  "; 
    95          $sth = $dbh->prepare($query); 
    96         $sth->execute(); 
     90    $sth = $dbh->prepare($stmt{'singletranscode.3'}); 
     91    $sth->execute($tid); 
    9792 @subticount= $sth->fetchrow_array; 
    9893 
     
    120115# PSP ------------------------------------------------------ 
    121116#PSPトラコン必要かどうか 
    122 $DBQuery =  "SELECT psp,aspect,title FROM  foltia_program WHERE tid = '$tid' "; 
    123          $sth = $dbh->prepare($DBQuery); 
    124         $sth->execute(); 
     117$sth = $dbh->prepare($stmt{'singletranscode.4'}); 
     118$sth->execute($tid); 
    125119 @psptrcn= $sth->fetchrow_array; 
    126120 if ($psptrcn[0]  == 1 ){#トラコン番組 
     
    227221my $newestmp4filename = `cd $pspdirname ; ls -t *.MP4 | head -1`; 
    228222 if ($newestmp4filename =~ /M4V$tid/){ 
    229         $nowcountno = $' ; 
     223               $nowcountno = $' ;#' 
    230224                $nowcountno++; 
    231225                $pspfilnameft = sprintf("%02d",$nowcountno); 
     
    261255#最適化 
    262256 
    263 $DBQuery =  "SELECT subtitle  FROM  foltia_subtitle WHERE tid = '$tid' AND countno = '$countno' "; 
    264          $sth = $dbh->prepare($DBQuery); 
    265         $sth->execute(); 
     257    $sth = $dbh->prepare($stmt{'singletranscode.5'}); 
     258    $sth->execute($tid, $countno); 
    266259 @programtitle = $sth->fetchrow_array; 
    267260 
     
    285278 
    286279if (-e "$pspdirname/M4V".$pspfilname.".THM"){ 
    287 $timestamp =`date "+%Y%m%d-%H%M%S"`
     280       $timestamp = strftime("%Y%m%d-%H%M%S", localtime)
    288281chomp $timestamp; 
    289282        system("convert -crop 160x120+1+3 -resize 165x126\! $pspdirname/00000002.jpg $pspdirname/M4V".$pspfilname.".THM.".$timestamp.".THM"); 
     
    297290system("rm -rf $pspdirname/0000000*.jpg "); 
    298291 
    299  
    300  
    301  
    302292# MP4ファイル名をPIDレコードに書き込み 
    303293unless ($pid eq ""){ 
    304         $DBQuery =  " 
    305         UPDATE  foltia_subtitle   
    306         SET PSPfilename = 'M4V$pspfilname.MP4'  
    307         WHERE pid =  '$pid' "; 
    308          $sth = $dbh->prepare($DBQuery); 
    309         $sth->execute(); 
    310 &writelog("singletranscode UPDATEsubtitleDB  $DBQuery"); 
     294        $sth = $dbh->prepare($stmt{'singletranscode.6'}); 
     295        $sth->execute("M4V$pspfilname.MP4", $pid); 
     296        &writelog("singletranscode UPDATEsubtitleDB $stmt{'singletranscode.6'}"); 
    311297}else{ 
    312298&writelog("singletranscode PID not found"); 
    313299} 
    314300# MP4ファイル名をfoltia_mp4files挿入 
    315         $DBQuery =  "insert into  foltia_mp4files values ('$tid','M4V$pspfilname.MP4') "; 
    316          $sth = $dbh->prepare($DBQuery); 
    317         $sth->execute(); 
    318 &writelog("singletranscode UPDATEmp4DB  $DBQuery"); 
     301    $sth = $dbh->prepare($stmt{'singletranscode.7'}); 
     302    $sth->execute($tid, "M4V$pspfilname.MP4"); 
     303    &writelog("singletranscode UPDATEmp4DB $stmt{'singletranscode.7'}"); 
    319304 
    320305}#PSPトラコンあり 
    321  
    322  
  • trunk/install/perl/tvrecording.pl

    r83 r94  
    2929$path = $0; 
    3030$path =~ s/tvrecording.pl$//i; 
    31 if ($pwd ne "./"){ 
     31if ($path ne "./"){ 
    3232push( @INC, "$path"); 
    3333} 
     
    301301#               $outputfile .= "$ARGV[3]"; 
    302302#               }else{ 
    303 #               $outputfile .= `date  +%Y%m%d-%H%M --date "1 min "`
     303#               $outputfile .= strftime("%Y%m%d-%H%M", localtime(time + 60))
    304304#               } 
    305305                $outputfile = $ARGV[3]; 
     
    308308                $outputfile = $outputpath.$outputfile ; 
    309309#               $outputfile .= "$ARGV[3]";               
    310 #               $outputfile .= `date  +%Y%m%d-%H%M --date "1 min "`
     310#               $outputfile .= strftime("%Y%m%d-%H%M", localtime(time + 60))
    311311                &writelog("tvrecording:  DEBUG ARGV[2] ne null  \$outputfile $outputfile "); 
    312312        }else{ 
    313                $outputfile .= `date  +%Y%m%d-%H%M --date "1 min "`
     313        $outputfile .= strftime("%Y%m%d-%H%M", localtime(time + 60))
    314314                chomp($outputfile); 
    315315                $outputfile .= ".m2p"; 
  • trunk/install/perl/updatem2pfiletable.pl

    r83 r94  
    1616use DBI; 
    1717use DBD::Pg; 
     18use DBD::SQLite; 
    1819 
    1920$path = $0; 
    2021$path =~ s/updatem2pfiletable.pl$//i; 
    21 if ($pwd ne "./"){ 
     22if ($path ne "./"){ 
    2223push( @INC, "$path"); 
    2324} 
    2425 
    2526require "foltialib.pl"; 
    26         my $data_source = sprintf("dbi:%s:dbname=%s;host=%s;port=%d", 
    27                 $DBDriv,$DBName,$DBHost,$DBPort); 
    28          $dbh = DBI->connect($data_source,$DBUser,$DBPass) ||die $DBI::error;; 
     27$dbh = DBI->connect($DSN,$DBUser,$DBPass) ||die $DBI::error;; 
    2928 
    3029$dbh->{AutoCommit} = 0; 
    3130# ひとまず消す 
    32 $query =  "DELETE  FROM  foltia_m2pfiles  "; 
    33          $sth = $dbh->prepare($query); 
     31$sth = $dbh->prepare($stmt{'updatem2pfiletable.1'}); 
    3432        $sth->execute(); 
    3533 
    3634while ($file = glob("$recfolderpath/*.m2?")) { 
    3735$file =~ s/$recfolderpath\///; 
    38 $query =  "insert into  foltia_m2pfiles values ('$file')"
    39 $oserr = $dbh->do($query); 
     36    $sth = $dbh->prepare($stmt{'updatem2pfiletable.2'})
     37    $sth->execute($file); 
    4038# print "$file\n"; 
    4139}#while 
     
    4644 
    4745# ひとまず消す 
    48 $query =  "DELETE  FROM  foltia_mp4files  "; 
    49          $sth = $dbh->prepare($query); 
     46$sth = $dbh->prepare($stmt{'updatem2pfiletable.3'}); 
    5047        $sth->execute(); 
    5148 
     
    5855$filetid =~ s/[^0-9]//g; 
    5956if (($filetid ne "" )&& ($fileline[2] ne "" )){ 
    60         $query =  "insert into  foltia_mp4files values ('$filetid','$fileline[2]')"
    61         $oserr = $dbh->do($query); 
     57        $sth = $dbh->prepare($stmt{'updatem2pfiletable.4'})
     58        $oserr = $sth->execute($filetid, $fileline[2]); 
    6259#print "$filetid;$fileline[2];$query\n" 
    6360# http://www.atmarkit.co.jp/fnetwork/rensai/sql03/sql1.html 
  • trunk/install/perl/xmltv2foltia.pl

    r38 r94  
    3030use DBI; 
    3131use DBD::Pg; 
     32use DBD::SQLite; 
    3233 
    3334$path = $0; 
    3435$path =~ s/xmltv2foltia.pl$//i; 
    35 if ($pwd ne "./"){ 
     36if ($path ne "./"){ 
    3637push( @INC, "$path"); 
    3738} 
     
    4041$currentworkdate = "" ; 
    4142$currentworkch = "" ; 
    42 $today =`date "+%Y%m%d"`
    43 $todaytime =`date "+%Y%m%d%H%M"`
     43$today = strftime("%Y%m%d", localtime)
     44$todaytime = strftime("%Y%m%d%H%M", localtime)
    4445 
    4546# DB Connect 
    46         my $data_source = sprintf("dbi:%s:dbname=%s;host=%s;port=%d", 
    47                 $DBDriv,$DBName,$DBHost,$DBPort); 
    48          $dbh = DBI->connect($data_source,$DBUser,$DBPass) ||die $DBI::error;; 
     47$dbh = DBI->connect($DSN,$DBUser,$DBPass) ||die $DBI::error;; 
     48$dbh->{AutoCommit} = 0; 
    4949 
    5050while(<>){ 
     
    187187}elsif(/<\/programme>/){ 
    188188#登録処理はココで 
    189 #&writelog("xmltv2foltia DEBUG call chkerase $item{start},$item{channel}"); 
    190  
    191 &chkerase($item{start},$item{channel}); 
    192 if ($item{subtitle} ne "" ){ 
    193         $registdesc = $item{subtitle}." ".$item{desc}; 
     189#&writelog("xmltv2foltia DEBUG call chkerase $item{'start'},$item{'channel'}"); 
     190 
     191       &chkerase($item{'start'}, $item{'channel'}); 
     192       if ($item{'subtitle'} ne "" ){ 
     193            $registdesc = $item{'subtitle'}." ".$item{'desc'}; 
    194194}else{ 
    195         $registdesc = $item{desc}; 
     195            $registdesc = $item{'desc'}; 
    196196} 
    197 &registdb($item{start},$item{stop},$item{channel},$item{title},$registdesc ,$item{category}); 
     197       &registdb($item{'start'},$item{'stop'},$item{'channel'},$item{'title'},$registdesc ,$item{'category'}); 
    198198 
    199199#       print "$item{start} 
     
    216216}# while 
    217217 
     218$dbh->commit; 
     219 
     220#end 
     221################ 
     222 
    218223sub chkerase{ 
    219224# xmltvからきた日付とチャンネルをfoltia epgと比較 
     
    232237# 新規に入る予定の未来の番組表、全部いったん消す 
    233238# $DBQuery =  "DELETE from foltia_epg where startdatetime > $epgstartdatetime AND ontvchannel = '$ontvepgchannel' "; 
    234  $DBQuery =  "DELETE from foltia_epg where startdatetime > $todaytime AND ontvchannel = '$ontvepgchannel' "; 
    235          $sth = $dbh->prepare($DBQuery); 
    236         $sth->execute(); 
    237 &writelog("xmltv2foltia DELETE EPG $epgstartdatetime:$DBQuery"); 
     239            $sth = $dbh->prepare($stmt{'xmltv2foltia.chkerase.1'}); 
     240            $sth->execute($todaytime, $ontvepgchannel); 
     241            &writelog("xmltv2foltia DELETE EPG $epgstartdatetime:$stmt{'xmltv2foltia.chkerase.1'}"); 
    238242#$currentworkdate = "$today"; 
    239243$currentworkch = $ontvepgchannel ; 
     
    261265if($foltiastarttime > $todaytime){ 
    262266         
    263         my $DBQuery =  "SELECT max(epgid) FROM foltia_epg "; 
    264                  $sth = $dbh->prepare($DBQuery); 
     267        $sth = $dbh->prepare($stmt{'xmltv2foltia.registdb.1'}); 
    265268                $sth->execute(); 
    266269         @currentepgid = $sth->fetchrow_array; 
     
    274277#&writelog("xmltv2foltia DEBUG $currentepgid[0] /  $newepgid"); 
    275278my $lengthmin = &calclength($foltiastarttime , $foltiaendtime); 
    276 $newepgid = $dbh->quote($newepgid ); 
    277 $foltiastarttime = $dbh->quote($foltiastarttime); 
    278 $foltiaendtime = $dbh->quote($foltiaendtime ); 
    279 $lengthmin = $dbh->quote($lengthmin ); 
    280 $channel = $dbh->quote($channel ); 
    281 $title = $dbh->quote($title); 
    282 $desc = $dbh->quote($desc); 
    283 $category = $dbh->quote($category); 
    284  
    285 $DBQuery =  "insert into  foltia_epg values ($newepgid,$foltiastarttime,$foltiaendtime,$lengthmin,$channel,$title,$desc,$category)"; 
    286 #       $DBQuery = $dbh->quote($DBQuery); 
    287          $sth = $dbh->prepare($DBQuery); 
    288         $sth->execute(); 
    289  
     279#       $newepgid = $dbh->quote($newepgid ); 
     280#       $foltiastarttime = $dbh->quote($foltiastarttime); 
     281#       $foltiaendtime = $dbh->quote($foltiaendtime ); 
     282#       $lengthmin = $dbh->quote($lengthmin ); 
     283#       $channel = $dbh->quote($channel ); 
     284#       $title = $dbh->quote($title); 
     285#       $desc = $dbh->quote($desc); 
     286#       $category = $dbh->quote($category); 
     287 
     288        $sth = $dbh->prepare($stmt{'xmltv2foltia.registdb.2'}); 
     289        $sth->execute($newepgid, $foltiastarttime, $foltiaendtime, $lengthmin, $channel, $title, $desc, $category) || 
     290            warn "error: $newepgid, $foltiastarttime, $foltiaendtime, $lengthmin, $channel, $title, $desc, $category\n"; 
    290291 
    291292# &writelog("xmltv2foltia DEBUG $DBQuery"); 
  • trunk/install/php/StarlightBreaker/sb-edit.php

    r88 r94  
    7373FROM foltia_subtitle , foltia_program ,foltia_station   
    7474WHERE foltia_program.tid = foltia_subtitle.tid AND foltia_station.stationid = foltia_subtitle.stationid  
    75  AND foltia_subtitle.pid = '$pid'  
    76   
    77        "
    78         $rs = m_query($con, $query, "DBクエリに失敗しました"); 
     75AND foltia_subtitle.pid = ?  
     76"; 
     77//     $rs = m_query($con, $query, "DBクエリに失敗しました")
     78        $rs = sql_query($con, $query, "DBクエリに失敗しました",array($pid)); 
    7979$rows = pg_num_rows($rs); 
    8080if ($rows == 0){ 
  • trunk/install/php/accountregist.php

    r70 r94  
    5858if ($username != ""){ 
    5959$query = " 
    60 SELECT memberid ,userclass,name,passwd1  
     60SELECT count(memberid) 
    6161FROM foltia_envpolicy  
    62 WHERE foltia_envpolicy.name  = '$username'   
     62WHERE foltia_envpolicy.name  = ?   
    6363"; 
    64         $isaccountexist = m_query($con, $query, "DBクエリに失敗しました"); 
    65         $isaccountexistncount = pg_num_rows($isaccountexist); 
     64//      $isaccountexist = m_query($con, $query, "DBクエリに失敗しました"); 
     65        $isaccountexist = sql_query($con, $query, "DBクエリに失敗しました",array($username)); 
     66 
     67        $isaccountexistncount = $isaccountexist->fetchColumn(0); 
    6668 
    6769        if ($isaccountexistncount == 0){ 
     
    8587"; 
    8688        $rs = m_query($con, $query, "DBクエリに失敗しました"); 
    87         $maxrows = pg_num_rows($rs); 
    88         if ($maxrows == 0)
    89         $nextcno = 1
     89        $maxid = $rs->fetchColumn(0); 
     90        if ($maxid)
     91               $nextcno = $maxid + 1
    9092        }else{ 
    91         $rowdata = pg_fetch_row($rs, 0); 
    92         $nextcno = $rowdata[0]; 
    93         $nextcno++ ; 
     93                $nextcno = 1; 
    9494        } 
    9595 
     
    110110$query = " 
    111111insert into foltia_envpolicy   
    112 values ( '$nextcno','2','$username','$userpasswd',now(),'$remotehost')"; 
     112values ( ?,'2',?,?,now(),?)"; 
    113113//print "$query <br>\n"; 
    114         $rs = m_query($con, $query, "DBクエリに失敗しました"); 
     114//      $rs = m_query($con, $query, "DBクエリに失敗しました"); 
     115        $rs = sql_query($con, $query, "DBクエリに失敗しました",array($nextcno,$username,$userpasswd,$remotehost)); 
    115116 
    116117print "次のアカウントを登録しました。<br> 
  • trunk/install/php/delepgp.php

    r84 r94  
    7070WHERE foltia_subtitle.tid = 0 AND  
    7171foltia_station.stationid = foltia_subtitle.stationid AND  
    72 foltia_subtitle.pid = $pid  
     72foltia_subtitle.pid = ?  
    7373 "; 
    7474 
    75       $rs = m_query($con, $query, "DBクエリに失敗しました"); 
    76         $maxrows = pg_num_rows($rs); 
    77                          
    78                if ($maxrows == 0) { 
     75//    $rs = m_query($con, $query, "DBクエリに失敗しました"); 
     76        $rs = sql_query($con, $query, "DBクエリに失敗しました",array($pid)); 
     77$rowdata = $rs->fetch(); 
     78if (! $rowdate) { 
    7979                die_exit("登録番組がありません<BR>"); 
    8080                } 
    81                 $rowdata = pg_fetch_row($rs, 0); 
    8281 
    8382                $pid = htmlspecialchars($rowdata[0]); 
     
    114113                DELETE   
    115114                FROM  foltia_subtitle   
    116                 WHERE foltia_subtitle.pid = $pid AND  foltia_subtitle.tid = 0 "; 
    117                         $rs = m_query($con, $query, "DBクエリに失敗しました"); 
     115                WHERE foltia_subtitle.pid = ? AND  foltia_subtitle.tid = 0 "; 
     116//                      $rs = m_query($con, $query, "DBクエリに失敗しました"); 
     117                        $rs = sql_query($con, $query, "DBクエリに失敗しました",array($pid)); 
    118118                } 
    119119        }else{ 
  • trunk/install/php/deletemovie.php

    r76 r94  
    8888FROM foltia_subtitle , foltia_program    
    8989WHERE foltia_program.tid = foltia_subtitle.tid   
    90  AND foltia_subtitle.tid = $filesplit[0]  
     90 AND foltia_subtitle.tid = ?  
    9191"; 
    92 $rs = m_query($con, $query, "DBクエリに失敗しました"); 
    93 $rowdata = pg_fetch_row($rs, $row); 
     92//$rs = m_query($con, $query, "DBクエリに失敗しました"); 
     93$rs = sql_query($con, $query, "DBクエリに失敗しました",array($filesplit[0])); 
     94                                $rall = $rs->fetchAll(); 
     95                                $rowdata = $rall[$row]; 
    9496//print" $fName./$rowdata[1]//$rowdata[2]<BR>\n"; 
    9597$title = $rowdata[1]; 
     
    103105FROM foltia_subtitle , foltia_program    
    104106WHERE foltia_program.tid = foltia_subtitle.tid   
    105  AND foltia_subtitle.tid = $filesplit[0]  
    106  AND foltia_subtitle.countno = $filesplit[1]  
     107 AND foltia_subtitle.tid = ?  
     108 AND foltia_subtitle.countno = ?  
    107109"; 
    108 $rs = m_query($con, $query, "DBクエリに失敗しました"); 
    109 $rowdata = pg_fetch_row($rs, $row); 
     110//$rs = m_query($con, $query, "DBクエリに失敗しました"); 
     111$rs = sql_query($con, $query, "DBクエリに失敗しました",array($filesplit[0] ,$filesplit[1])); 
     112                                $rall = $rs->fetchAll(); 
     113                                $rowdata = $rall[$row]; 
    110114//print" $fName./$rowdata[1]/$rowdata[2]/$rowdata[3]<BR>\n"; 
    111115$title = $rowdata[1]; 
     
    119123$count = htmlspecialchars($count); 
    120124$subtitle = htmlspecialchars($subtitle); 
    121  
    122 //-- 
    123  
    124125 
    125126print " 
     
    138139$query = " 
    139140DELETE  FROM  foltia_m2pfiles   
    140 WHERE m2pfilename = '$fName'  
     141WHERE m2pfilename = ?  
    141142"; 
    142 $rs = m_query($con, $query, "DBクエリに失敗しました"); 
     143//$rs = m_query($con, $query, "DBクエリに失敗しました"); 
     144$rs = sql_query($con, $query, "DBクエリに失敗しました",array($fName)); 
    143145 
    144146//削除処理 
  • trunk/install/php/delreserve.php

    r70 r94  
    4444<?php 
    4545 
    46  
    47 $tid = getgetnumform(tid); 
     46    $tid = getgetnumform("tid"); 
    4847                if ($tid == "") { 
    4948                die_exit("番組がありません<BR>"); 
    5049                } 
    51 $sid = getgetnumform(sid); 
     50    $sid = getgetnumform("sid"); 
    5251                if ($sid == "") { 
    5352                die_exit("局がありません<BR>"); 
     
    7069foltia_tvrecord.stationid   
    7170FROM  foltia_tvrecord , foltia_program , foltia_station  
    72 WHERE foltia_tvrecord.tid = foltia_program.tid  AND foltia_tvrecord.stationid = foltia_station .stationid  AND foltia_tvrecord.tid = $tid AND foltia_tvrecord.stationid = $sid  "; 
    73  
    74         $rs = m_query($con, $query, "DBクエリに失敗しました"); 
    75         $maxrows = pg_num_rows($rs); 
    76                          
    77                 if ($maxrows == 0) { 
     71WHERE foltia_tvrecord.tid = foltia_program.tid  AND foltia_tvrecord.stationid = foltia_station .stationid  AND foltia_tvrecord.tid = ? AND foltia_tvrecord.stationid = ?  "; 
     72 
     73//      $rs = m_query($con, $query, "DBクエリに失敗しました"); 
     74        $rs = sql_query($con, $query, "DBクエリに失敗しました",array($tid,$sid)); 
     75$rowdata = $rs->fetch(); 
     76 
     77if (! $rowdata ) { 
    7878                die_exit("登録番組がありません<BR>"); 
    7979                } 
    80                 $rowdata = pg_fetch_row($rs, 0); 
    81  
    8280                $tid = htmlspecialchars($rowdata[0]); 
    8381                $stationname = htmlspecialchars($rowdata[1]); 
     
    107105DELETE   
    108106FROM  foltia_tvrecord   
    109 WHERE foltia_tvrecord.tid = $tid AND foltia_tvrecord.stationid = $sid  "; 
    110         $rs = m_query($con, $query, "DBクエリに失敗しました"); 
     107WHERE foltia_tvrecord.tid = ? AND foltia_tvrecord.stationid = ?  "; 
     108$rs->closeCursor(); 
     109//      $rs = m_query($con, $query, "DBクエリに失敗しました"); 
     110        $rs = sql_query($con, $query, "DBクエリに失敗しました",array($tid,$sid)); 
    111111} 
    112112 
     
    164164FROM foltia_subtitle , foltia_program ,foltia_station   
    165165WHERE foltia_program.tid = foltia_subtitle.tid AND foltia_station.stationid = foltia_subtitle.stationid  
    166  AND foltia_subtitle.startdatetime >= '$now'  AND foltia_program.tid ='$tid'  
     166 AND foltia_subtitle.startdatetime >= ?  AND foltia_program.tid = ?  
    167167ORDER BY foltia_subtitle.startdatetime  ASC 
    168168"; 
    169       $rs = m_query($con, $query, "DBクエリに失敗しました"); 
    170         $maxrows = pg_num_rows($rs); 
    171                          
    172                if ($maxrows == 0) { 
     169//    $rs = m_query($con, $query, "DBクエリに失敗しました"); 
     170        $rs = sql_query($con, $query, "DBクエリに失敗しました",array($now,$tid)); 
     171$rowdata = $rs->fetch(); 
     172if (! $rowdata) { 
    173173                echo("放映予定はありません<BR>"); 
    174                 } 
    175                 else{ 
    176                 $maxcols = pg_num_fields($rs);           
     174}else{ 
     175        $maxcols = $rs->columnCount(); 
    177176?> 
    178177  <table BORDER="0" CELLPADDING="0" CELLSPACING="2" WIDTH="100%" BGCOLOR="#bcf1be"> 
     
    192191                <?php 
    193192                        /* テーブルのデータを出力 */ 
    194                        for ($row = 0; $row < $maxrows; $row++) { /* 行に対応 */ 
     193             do { 
    195194                                echo("<tr>\n"); 
    196                                 /* pg_fetch_row で一行取り出す */ 
    197                                 $rowdata = pg_fetch_row($rs, $row); 
    198  
    199195                                for ($col = 0; $col < $maxcols; $col++) { /* 列に対応 */ 
    200196                                        echo("<td>".htmlspecialchars($rowdata[$col])."<br></td>\n"); 
    201197                                } 
    202198                                echo("</tr>\n"); 
    203                        } 
     199             } while ($row = $rs->fetch()); 
    204200                }//end if 
    205201                ?> 
  • trunk/install/php/folcast.php

    r70 r94  
    5151$query = " 
    5252SELECT  foltia_program.tid,foltia_program.title, 
    53 foltia_subtitle.countno , foltia_subtitle.subtitle , foltia_subtitle.startdatetime, foltia_subtitle.pspfilename,foltia_subtitle.lengthmin,foltia_subtitle.enddatetime   FROM foltia_subtitle , foltia_program   WHERE \"pspfilename\" ~~ 'M%%'  AND foltia_program.tid = foltia_subtitle.tid AND foltia_program.tid = $tid    
     53foltia_subtitle.countno , foltia_subtitle.subtitle , foltia_subtitle.startdatetime, foltia_subtitle.pspfilename,foltia_subtitle.lengthmin,foltia_subtitle.enddatetime   FROM foltia_subtitle , foltia_program   WHERE \"pspfilename\" LIKE 'M%%'  AND foltia_program.tid = foltia_subtitle.tid AND foltia_program.tid = $tid    
    5454ORDER BY \"enddatetime\" DESC  
    5555offset 0 limit  $max  
     
    5959SELECT  foltia_program.tid,foltia_program.title  
    6060FROM  foltia_program    
    61 WHERE foltia_program.tid = $tid    
     61WHERE foltia_program.tid = ?    
    6262"; 
    63         $titlers = m_query($con, $query, "DBクエリに失敗しました"); 
    64         $rowdata = pg_fetch_row($titlers, 0);  
     63//      $titlers = m_query($con, $query, "DBクエリに失敗しました"); 
     64        $titlers = sql_query($con, $query, "DBクエリに失敗しました",array($tid)); 
     65        $rowdata = $titlers->fetch(); 
    6566        $rsstitle = $rowdata[1]; 
    6667}else{ 
     
    6869$query = " 
    6970SELECT  foltia_program.tid,foltia_program.title, 
    70 foltia_subtitle.countno , foltia_subtitle.subtitle , foltia_subtitle.startdatetime, foltia_subtitle.pspfilename,foltia_subtitle.lengthmin,foltia_subtitle.enddatetime   FROM foltia_subtitle , foltia_program   WHERE \"pspfilename\" ~~ 'M%%'  AND foltia_program.tid = foltia_subtitle.tid ORDER BY \"enddatetime\" DESC  
    71 offset 0 limit  $max  
     71foltia_subtitle.countno , foltia_subtitle.subtitle , foltia_subtitle.startdatetime, foltia_subtitle.pspfilename,foltia_subtitle.lengthmin,foltia_subtitle.enddatetime   FROM foltia_subtitle , foltia_program   WHERE \"pspfilename\" LIKE 'M%%'  AND foltia_program.tid = foltia_subtitle.tid ORDER BY \"enddatetime\" DESC  
     72offset 0 limit  ?  
    7273        "; 
    7374        $rsstitle = "新規録画"; 
     
    9697print $header; 
    9798 
    98         $rs = m_query($con, $query, "DBクエリに失敗しました"); 
    99         $maxrows = pg_num_rows($rs); 
     99//      $rs = m_query($con, $query, "DBクエリに失敗しました"); 
     100        $rs = sql_query($con, $query, "DBクエリに失敗しました",array($max)); 
     101$rowdata = $rs->fetch(); 
    100102 
    101 if ($maxrows == 0) { 
     103if (! $rowdata) { 
    102104                                //die_exit("No items");  
    103105}else{ 
    104  
    105 for ($row = 0; $row < $maxrows; $row++) {  
    106                 $rowdata = pg_fetch_row($rs, $row); 
    107                  
     106        do { 
    108107//$title = mb_convert_encoding($rowdata[1],"UTF-8", "EUC-JP"); 
    109108$tid =  $rowdata[0]; 
     
    163162print $item ; 
    164163 
    165 }//for 
     164        } while ($rowdata = $rs->fetch()); //do 
    166165 
    167166}//if 
  • trunk/install/php/foltia_config2.php.template

    r83 r94  
    2727 
    2828// データベース接続設定 
    29         define("DATABASE_NAME", "foltia"); 
    30         define("DBHOST", "localhost"); 
    31         define("USER_NAME"    , "foltia"    ); 
    32         define("USER_PASSWORD", "passwd"    ); 
     29// define("DSN", "pgsql:host=localhost dbname=foltia user=foltia password= "); 
     30define("DSN", "sqlite:/home/foltia/foltia.sqlite"); 
    3331 
    3432//        $mylocalip = "192.168.0.177" ; //動いている機械のIPアドレス 
  • trunk/install/php/foltialib.php

    r89 r94  
    9393                } 
    9494        } 
    95          
    96         /* LIKE 用の文字列のエスケープ */ 
    97         function escape_like($sql, $quote = TRUE) { 
    98                 return ($quote ? "'" : "") . 
    99                        str_replace(array("\\\\",     "%"    , "_"    ), 
    100                                    array("\\\\\\\\", "\\\\%", "\\\\_"), 
    101                                    pg_escape_string($sql)) . 
    102                        ($quote ? "'" : ""); 
    103         } 
    104          
     95 
    10596        /* SQL 文字列のエスケープ */ 
    10697        function escape_string($sql, $quote = FALSE) { 
     
    10899                        return "null"; 
    109100                } 
     101                if (preg_match("/^pgsql/", DSN)){ 
    110102                return ($quote ? "'" : "") . 
    111103                       pg_escape_string($sql) . 
    112104                       ($quote ? "'" : ""); 
    113         } 
     105                }else if (preg_match("/^sqlite/", DSN)){ 
     106                /*      return ($quote ? "'" : "") . 
     107                                sqlite_escape_string($sql) . 
     108                                ($quote ? "'" : ""); 
     109                */ 
     110                return($sql); 
     111                }else{ 
     112                        return "null"; 
     113                } 
     114        }  
    114115         
    115116        /* SQL 数値のエスケープ */ 
     
    124125        } 
    125126         
    126         /* PostgreSQL サーバに接続 */ 
     127        /* DBに接続 */ 
    127128        function m_connect() {  
    128 /*              $con = @pg_connect("host=".DBHOST ." dbname=".DATABASE_NAME . 
    129                                    " user=".USER_NAME . 
    130                                    " password=".USER_PASSWORD); 
    131 */ 
    132                 $con = @pg_pconnect("host=".DBHOST ." dbname=".DATABASE_NAME . 
    133                                    " user=".USER_NAME . 
    134                                    " password=".USER_PASSWORD); 
    135  
    136  
    137                 if (!$con) { 
    138                         die_exit("データベースに接続出来ませんでした。"); 
     129        try { 
     130                $dbh = new PDO(DSN); 
     131                $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); 
     132                return($dbh); 
     133        } catch (PDOException $e) { 
     134                die_exit($e->getMessage() . ": データベースに接続出来ませんでした。"); 
    139135                } 
    140136                /* データベースと、PHP の内部文字コードが違う場合 */ 
    141                 return($con); 
    142137        } 
    143138 
    144139        /* データベースとの接続を切り離す */ 
    145         function m_close($con) { 
    146                 return @pg_close($con); 
    147         } 
    148  
    149         /* SQL 文を実行 */ 
    150         function m_query($con, $query, $errmessage) { 
    151                 $rtn = @pg_query($con, $query); 
    152                 if (!$rtn) { 
     140function m_close($dbh) { 
     141        return null; 
     142        } 
     143 
     144//旧関数 sql_queryに置き換え 
     145function m_query($dbh, $query, $errmessage) { 
     146        try { 
     147                $rtn = $dbh->query($query); 
     148                return($rtn); 
     149        } catch (PDOException $e) { 
    153150                        /* エラーメッセージに SQL 文を出すのはセキュリティ上良くない!! */ 
    154151                        $msg = $errmessage . "<br>\n" . 
    155                                @pg_last_error($con) . "<br>\n" . 
     152                    $e->getMessage() . "<br>\n" . 
     153                    var_export($e->errorInfo, true) . "<br>\n" . 
    156154                               "<small><code>" . htmlspecialchars($query) . 
    157155                               "</code></small>\n"; 
    158                                $rtn = @pg_query($con, "rollback");//04.4.8 
    159                        m_close($con)
     156//              $dbh->rollBack(); 
     157                $dbh = null
    160158                        die_exit($msg); 
    161159                } 
     160        } 
     161/* SQL 文を実行 */ 
     162function sql_query($dbh, $query, $errmessage,$paramarray) { 
     163        try { 
     164                $rtn = $dbh->prepare("$query"); 
     165                $rtn->execute($paramarray); 
    162166                return($rtn); 
     167        } catch (PDOException $e) { 
     168                        /* エラーメッセージに SQL 文を出すのはセキュリティ上良くない!! */ 
     169                        $msg = $errmessage . "<br>\n" . 
     170                    $e->getMessage() . "<br>\n" . 
     171                    var_export($e->errorInfo, true) . "<br>\n" . 
     172                               "<small><code>" . htmlspecialchars($query) . 
     173                               "</code></small>\n"; 
     174//              $dbh->rollBack(); 
     175                $dbh = null; 
     176                        die_exit($msg); 
     177                } 
    163178        } 
    164179 
     
    166181        function m_showtable($rs) { 
    167182                /* 検索件数 */ 
    168                $maxrows = pg_num_rows($rs)
     183        $maxrows = 0
    169184                 
    170                 if ($maxrows == 0) { 
     185        $rowdata = $rs->fetch(); 
     186        if (! $rowdata) { 
    171187                        echo("<p class=\"msg\">データが存在しません</p>\n"); 
    172188                        return 0; 
     
    174190                 
    175191                /* フィールド数 */ 
    176                $maxcols = pg_num_fields($rs); 
     192        $maxcols = $rs->columnCount(); 
    177193                ?> 
    178194<table class="list" summary="データ検索結果を表示" border="1"> 
     
    183199                                for ($col = 1; $col < $maxcols; $col++) { 
    184200                                        /* pg_field_name() はフィールド名を返す */ 
    185                                         $f_name = htmlspecialchars(pg_field_name($rs, $col)); 
     201                     $meta = $rs->getColumnMeta($col); 
     202                     $f_name = htmlspecialchars($meta["name"]); 
    186203                                        echo("<th abbr=\"$f_name\">$f_name</th>\n"); 
    187204                                } 
     
    192209                <?php 
    193210                        /* テーブルのデータを出力 */ 
    194                         for ($row = 0; $row < $maxrows; $row++) { /* 行に対応 */ 
     211              do { 
     212                      $maxrows++; 
     213 
    195214                                echo("<tr>\n"); 
    196                                 /* pg_fetch_row で一行取り出す */ 
    197                                 $rowdata = pg_fetch_row($rs, $row); 
    198215                                /* 1列目にリンクを張る */ 
    199216                                echo("<td><a href=\"edit.php?q_code=" . 
     
    204221                                } 
    205222                                echo("</tr>\n"); 
    206                        } 
     223              } while ($rowdata = $rs->fetch()); 
    207224                ?> 
    208225        </tbody> 
     
    212229        } 
    213230 
    214         /* 指定したコードのデータを表示 */ 
    215         function m_viewdata($con, $code) { 
    216                 /* コードに該当するデータを検索 */ 
    217                 $query = " 
     231 
     232function m_viewdata($dbh, $code) { 
     233 
     234/*これ使ってないよね? 
     235 
     236        $query = " 
    218237select p.code 
    219238      ,p.name 
     
    222241      ,s.name as job 
    223242      ,p.profile 
    224       ,to_char(p.editdate, 'YYYY/MM/DD HH24:MI:SS') as editdate 
     243      ,datetime(p.editdate) as editdate 
    225244  from inet_profile p left join inet_job s on p.job = s.code 
    226245 where p.code = $code"; 
    227                 $rs = m_query($con, $query, "個人情報の取得に失敗しました。"); 
    228                 if (pg_num_rows($rs) == 0) { 
     246        $rs = m_query($dbh, $query, "個人情報の取得に失敗しました。"); 
     247        $rowdata = $rs->fetch(); 
     248        if (! $rowdata) { 
    229249                        echo("<p class=\"msg\">データが存在しません</p>\n"); 
    230250                        return FALSE; 
    231251                } 
    232252                 
    233                 /* フィールド数 */ 
    234                 $maxcols = pg_num_fields($rs); 
    235                 /* 先頭行 */ 
    236                 $rowdata = pg_fetch_row($rs, 0); 
     253                // フィールド数  
     254        $maxcols = $rs->columnCount(); 
    237255                ?> 
    238256<table class="view" summary="データベース上のデータを表示" border="1"> 
    239257        <tr> 
    240                 <td class="name"><?= htmlspecialchars(pg_field_name($rs, 1)) ?></td> 
     258             <?php $meta = $rs->getColumnMeta(1); ?> 
     259             <td class="name"><?= htmlspecialchars($meta["name"]) ?></td> 
    241260                <td><a href="edit.php?q_code=<?= $rowdata[0] ?>" 
    242261                     ><?= htmlspecialchars($rowdata[1]) ?></a></td> 
    243262        </tr> 
    244         <?php for ($col = 2; $col < $maxcols; $col++) { ?> 
     263             <?php for ($col = 2; $col < $maxcols; $col++) { 
     264                $meta = $rs->getColumnMeta($col); ?> 
    245265        <tr> 
    246                <td class="name"><?= htmlspecialchars(pg_field_name($rs, $col)) ?></td> 
     266            <td class="name"><?= htmlspecialchars($meta["name"]) ?></td> 
    247267                <td><?= htmlspecialchars($rowdata[$col]) ?></td> 
    248268        </tr> 
     
    250270</table> 
    251271                <?php 
    252                 /* クエリーを解放 */ 
    253                 pg_free_result($rs); 
    254                  
     272                // クエリーを解放  
     273      $rs = null; 
    255274                return TRUE; 
     275*/ 
    256276        } 
    257277         
     
    294314        "; 
    295315        $rs = m_query($con, $query, "DBクエリに失敗しました"); 
    296         $maxrows = pg_num_rows($rs); 
    297 if ($maxrows == 0) { 
     316        $rowdata = $rs->fetch(); 
     317       if (! $rowdata) { 
    298318                print("番組データがありません<BR>");                        
    299319}else{ 
     
    301321//print "<ul><!-- ($maxrows) $query -->\n"; 
    302322 
    303 for ($row = 0; $row < $maxrows; $row++) {  
    304           
    305 $rowdata = pg_fetch_row($rs, $row); 
    306  
     323                do { 
    307324$printstarttime = substr($rowdata[0],8,2) . ":" .  substr($rowdata[0],10,2); 
    308325$tdclass = "t".substr($rowdata[0],8,2) .  substr($rowdata[0],10,2); 
     
    323340</li>\n"; 
    324341*/ 
    325 }//for 
     342                } while ($rowdata = $rs->fetch());//do 
    326343//print "</ul>\n"; 
    327344print "</table>\n"; 
     
    429446global $recfolderpath,$recfolderpath; 
    430447 
    431         exec ( "df -h  $recfolderpath | grep $recfolderpath", $hdfreearea); 
    432         $freearea = preg_split ("/[\s,]+/", $hdfreearea[0]); 
     448//      exec ( "df -h  $recfolderpath | grep $recfolderpath", $hdfreearea); 
     449//      $freearea = preg_split ("/[\s,]+/", $hdfreearea[0]); 
     450        exec ( "df -hP  $recfolderpath", $hdfreearea); 
     451        $freearea = preg_split ("/[\s,]+/", $hdfreearea[count($hdfreearea)-1]); 
    433452 
    434453    return $freearea; 
     
    557576        "; 
    558577        $useraccount = m_query($con, $query, "DBクエリに失敗しました"); 
    559         $useraccountrows = pg_num_rows($useraccount); 
    560          
    561         if ($useraccountrows == 1 ){ 
    562                 $rowdata = pg_fetch_row($useraccount, 0); 
     578                $rowdata = $useraccount->fetch(); 
     579                if (! $rowdata) { 
     580                        header("HTTP/1.0 401 Unauthorized"); 
     581                        redirectlogin(); 
     582                } 
     583         
    563584                $memberid = $rowdata[0]; 
    564585                $userclass = $rowdata[1]; 
    565586                $username =  $rowdata[2]; 
    566587                $dbpasswd = $rowdata[3]; 
    567         }else{ 
     588 
     589                $rowdata = $useraccount->fetch(); 
     590                if ($rowdata) { 
    568591                header("HTTP/1.0 401 Unauthorized"); 
    569                 //print "<!-- DEBUG DB record error ($useraccountrows)-->"; 
    570592                redirectlogin(); 
    571         }//end if 
    572  
     593                } 
    573594 
    574595// passwdをdbから取りだし 
     
    627648        "; 
    628649                $useraccount = m_query($con, $query, "DBクエリに失敗しました"); 
    629         $useraccountrows = pg_num_rows($useraccount); 
    630          
    631         if ($useraccountrows == 1 ){ 
    632                 $rowdata = pg_fetch_row($useraccount, 0); 
    633                 //$userclass = $rowdata[1]; 
    634                 return ($rowdata[1]); 
    635         }else{ 
    636         return (99);//エラー 
    637         }//end if 
     650                $rowdata = $useraccount->fetch(); 
     651                if (! $rowdata) { 
     652                        return (99); 
     653                } 
     654         
     655                $userclass = $rowdata[1]; 
     656 
     657                $rowdata = $useraccount->fetch(); 
     658                if ($rowdata) { 
     659                        return (99); 
     660                } 
     661 
     662                return ($userclass); 
    638663         
    639664}else{ 
     
    655680        "; 
    656681                $useraccount = m_query($con, $query, "DBクエリに失敗しました"); 
    657         $useraccountrows = pg_num_rows($useraccount); 
    658          
    659         if ($useraccountrows == 1 ){ 
    660                 $rowdata = pg_fetch_row($useraccount, 0); 
    661                 //$userclass = $rowdata[1]; 
    662                 return ($rowdata[0]); 
    663         }else{ 
     682                $rowdata = $useraccount->fetch(); 
     683                if (! $rowdata) { 
    664684        return (-1);//エラー 
    665         }//end if 
     685                } 
     686 
     687                $memberid = $rowdata[0]; 
     688 
     689                $rowdata = $useraccount->fetch(); 
     690                if ($rowdata) { 
     691                        return (-1); 
     692                } 
     693 
     694                return ($memberid); 
    666695         
    667696}else{ 
     
    682711        "; 
    683712                $useraccount = m_query($con, $query, "DBクエリに失敗しました"); 
    684         $useraccountrows = pg_num_rows($useraccount); 
    685          
    686         if ($useraccountrows == 1 ){ 
    687                 $rowdata = pg_fetch_row($useraccount, 0); 
    688                 return ($rowdata[2]); 
     713                $rowdata = $useraccount->fetch(); 
     714                if (! $rowdata) { 
     715        return ("");//エラー 
     716                } 
     717         
     718                $name = $rowdata[2]; 
     719 
     720                $rowdata = $useraccount->fetch(); 
     721                if ($rowdata) { 
     722        return (""); 
     723                } 
     724 
     725                return ($name); 
     726 
    689727        }else{ 
    690         return ("");//エラー 
     728               return (""); 
    691729        }//end if 
    692          
    693 }else{ 
    694         return (""); 
    695 }//end if 
    696  
    697  
    698730 
    699731}//end function getmemberid2name 
  • trunk/install/php/graytable.css

    r51 r94  
    1 body * {margin:0px;padding:0px;border:0px;} 
     1// body * {margin:0px;padding:0px;border:0px;} 
    22 
    33body { 
  • trunk/install/php/index.php

    r83 r94  
    6767WHERE foltia_tvrecord.tid = foltia_program.tid  
    6868AND foltia_program.tid = foltia_subtitle.tid  
    69 AND foltia_subtitle.enddatetime >= '$now'  
     69AND foltia_subtitle.enddatetime >= ?  
    7070ORDER BY \"startdatetime\" ASC  
    7171LIMIT 1000 
    7272        "; 
    73         $reservedrssametid = m_query($con, $query, "DBクエリに失敗しました"); 
    74         $reservedmaxrowssameid = pg_num_rows($reservedrssametid); 
    75          
    76         if ($reservedmaxrowssameid > 0 ){ 
    77         for ($rrow = 0; $rrow < $reservedmaxrowssameid ; $rrow++) { 
    78                 $rowdata = pg_fetch_row($reservedrssametid, $rrow); 
     73//      $reservedrssametid = m_query($con, $query, "DBクエリに失敗しました"); 
     74$reservedrssametid = sql_query($con, $query, "DBクエリに失敗しました",array($now)); 
     75$rowdata = $reservedrssametid->fetch(); 
     76if ($rowdata) { 
     77        do { 
    7978                $reservedpidsametid[] = $rowdata[7]; 
    80         } 
     79        } while ($rowdata = $reservedrssametid->fetch()); 
     80 
    8181        $rowdata = ""; 
    82         $rrow = "";  
    8382        }else{ 
    84         $reservedpidsametid = ""
     83        $reservedpidsametid = array()
    8584        }//end if 
     85$reservedrssametid->closeCursor(); 
    8686 
    8787//録画番組検索 
    8888$query = " 
    8989SELECT 
    90 foltia_program .tid, 
    91 stationname, 
    92 foltia_program .title, 
    93 foltia_subtitle.countno, 
    94 foltia_subtitle.subtitle, 
    95 foltia_subtitle.startdatetime , 
    96 foltia_subtitle.lengthmin , 
    97 foltia_tvrecord.bitrate , 
    98 foltia_subtitle.pid   
     90 foltia_program.tid, stationname, foltia_program.title, 
     91 foltia_subtitle.countno, foltia_subtitle.subtitle, 
     92 foltia_subtitle.startdatetime as x, foltia_subtitle.lengthmin, 
     93 foltia_tvrecord.bitrate, foltia_subtitle.pid 
    9994FROM foltia_subtitle , foltia_program ,foltia_station ,foltia_tvrecord 
    10095WHERE foltia_tvrecord.tid = foltia_program.tid AND foltia_tvrecord.stationid = foltia_station .stationid AND foltia_program.tid = foltia_subtitle.tid AND foltia_station.stationid = foltia_subtitle.stationid 
     
    10297UNION 
    10398SELECT 
    104 foltia_program .tid, 
    105 stationname, 
    106 foltia_program .title, 
    107 foltia_subtitle.countno, 
    108 foltia_subtitle.subtitle, 
    109 foltia_subtitle.startdatetime , 
    110 foltia_subtitle.lengthmin , 
    111 foltia_tvrecord.bitrate , 
    112 foltia_subtitle.pid   
     99 foltia_program.tid, stationname, foltia_program.title, 
     100 foltia_subtitle.countno, foltia_subtitle.subtitle, 
     101 foltia_subtitle.startdatetime, foltia_subtitle.lengthmin, 
     102 foltia_tvrecord.bitrate, foltia_subtitle.pid 
    113103FROM foltia_tvrecord 
    114104LEFT OUTER JOIN foltia_subtitle on (foltia_tvrecord.tid = foltia_subtitle.tid ) 
     
    116106LEFT OUTER JOIN foltia_station on (foltia_subtitle.stationid = foltia_station.stationid ) 
    117107WHERE foltia_tvrecord.stationid = 0 AND 
    118 foltia_subtitle.enddatetime >= '$now' ORDER BY \"startdatetime\" ASC  
    119 LIMIT 1000 
    120         "; 
    121  
    122         $reservedrs = m_query($con, $query, "DBクエリに失敗しました"); 
    123         $reservedmaxrows = pg_num_rows($reservedrs); 
    124          
    125         if ($reservedmaxrows > 0 ){ 
    126         for ($rrow = 0; $rrow < $reservedmaxrows ; $rrow++) { 
    127                 $rowdata = pg_fetch_row($reservedrs, $rrow); 
     108 foltia_subtitle.enddatetime >= '$now' ORDER BY x ASC 
     109LIMIT 1000 
     110        "; 
     111 
     112//$reservedrs = m_query($con, $query, "DBクエリに失敗しました"); 
     113$query = " 
     114SELECT 
     115 foltia_program.tid, stationname, foltia_program.title, 
     116 foltia_subtitle.countno, foltia_subtitle.subtitle, 
     117 foltia_subtitle.startdatetime as x, foltia_subtitle.lengthmin, 
     118 foltia_tvrecord.bitrate, foltia_subtitle.pid 
     119FROM foltia_subtitle , foltia_program ,foltia_station ,foltia_tvrecord 
     120WHERE foltia_tvrecord.tid = foltia_program.tid AND foltia_tvrecord.stationid = foltia_station .stationid AND foltia_program.tid = foltia_subtitle.tid AND foltia_station.stationid = foltia_subtitle.stationid 
     121AND foltia_subtitle.enddatetime >= ?  
     122UNION 
     123SELECT 
     124 foltia_program.tid, stationname, foltia_program.title, 
     125 foltia_subtitle.countno, foltia_subtitle.subtitle, 
     126 foltia_subtitle.startdatetime, foltia_subtitle.lengthmin, 
     127 foltia_tvrecord.bitrate, foltia_subtitle.pid 
     128FROM foltia_tvrecord 
     129LEFT OUTER JOIN foltia_subtitle on (foltia_tvrecord.tid = foltia_subtitle.tid ) 
     130LEFT OUTER JOIN foltia_program on (foltia_tvrecord.tid = foltia_program.tid ) 
     131LEFT OUTER JOIN foltia_station on (foltia_subtitle.stationid = foltia_station.stationid ) 
     132WHERE foltia_tvrecord.stationid = 0 AND 
     133 foltia_subtitle.enddatetime >= ? ORDER BY x ASC 
     134LIMIT 1000 
     135        "; 
     136$reservedrs = sql_query($con, $query, "DBクエリに失敗しました",array($now,$now)); 
     137 
     138$rowdata = $reservedrs->fetch(); 
     139if ($rowdata) { 
     140        do { 
    128141                $reservedpid[] = $rowdata[8]; 
    129         } 
     142        } while ($rowdata = $reservedrs->fetch()); 
    130143        }else{ 
    131         $reservedpid = ""
     144        $reservedpid = array()
    132145        }//end if 
    133146 
     
    138151        $query = " 
    139152        SELECT  
    140 foltia_program .tid, 
    141 stationname, 
    142 foltia_program .title, 
    143 foltia_subtitle.countno, 
    144 foltia_subtitle.subtitle, 
    145 foltia_subtitle.startdatetime , 
    146 foltia_subtitle.lengthmin  ,  
    147 foltia_subtitle.pid , 
    148 foltia_subtitle.startoffset    
     153 foltia_program.tid, stationname, foltia_program.title, 
     154 foltia_subtitle.countno, foltia_subtitle.subtitle, 
     155 foltia_subtitle.startdatetime, foltia_subtitle.lengthmin, 
     156 foltia_subtitle.pid, foltia_subtitle.startoffset 
    149157FROM foltia_subtitle , foltia_program ,foltia_station   
    150158WHERE foltia_program.tid = foltia_subtitle.tid AND foltia_station.stationid = foltia_subtitle.stationid  
     
    153161LIMIT 1000 
    154162        "; 
    155         $rs = m_query($con, $query, "DBクエリに失敗しました"); 
    156         $maxrows = pg_num_rows($rs); 
    157  
    158  
     163$query = " 
     164        SELECT  
     165 foltia_program.tid, stationname, foltia_program.title, 
     166 foltia_subtitle.countno, foltia_subtitle.subtitle, 
     167 foltia_subtitle.startdatetime, foltia_subtitle.lengthmin, 
     168 foltia_subtitle.pid, foltia_subtitle.startoffset 
     169FROM foltia_subtitle , foltia_program ,foltia_station   
     170WHERE foltia_program.tid = foltia_subtitle.tid AND foltia_station.stationid = foltia_subtitle.stationid  
     171 AND foltia_subtitle.enddatetime >= ?  AND foltia_subtitle.countno = '1'  
     172ORDER BY foltia_subtitle.startdatetime  ASC  
     173LIMIT 1000 
     174        "; 
    159175}else{ 
    160        $query = " 
     176$query = " 
    161177        SELECT  
    162 foltia_program .tid, 
    163 stationname, 
    164 foltia_program .title, 
    165 foltia_subtitle.countno, 
    166 foltia_subtitle.subtitle, 
    167 foltia_subtitle.startdatetime , 
    168 foltia_subtitle.lengthmin ,  
    169 foltia_subtitle.pid  ,  
    170 foltia_subtitle.startoffset    
     178 foltia_program.tid, stationname, foltia_program.title, 
     179 foltia_subtitle.countno, foltia_subtitle.subtitle, 
     180 foltia_subtitle.startdatetime, foltia_subtitle.lengthmin, 
     181 foltia_subtitle.pid, foltia_subtitle.startoffset 
    171182FROM foltia_subtitle , foltia_program ,foltia_station   
    172183WHERE foltia_program.tid = foltia_subtitle.tid AND foltia_station.stationid = foltia_subtitle.stationid  
     
    175186LIMIT 1000 
    176187        "; 
    177         $rs = m_query($con, $query, "DBクエリに失敗しました"); 
    178         $maxrows = pg_num_rows($rs); 
    179  
     188$query = " 
     189        SELECT  
     190 foltia_program.tid, stationname, foltia_program.title, 
     191 foltia_subtitle.countno, foltia_subtitle.subtitle, 
     192 foltia_subtitle.startdatetime, foltia_subtitle.lengthmin, 
     193 foltia_subtitle.pid, foltia_subtitle.startoffset 
     194FROM foltia_subtitle , foltia_program ,foltia_station   
     195WHERE foltia_program.tid = foltia_subtitle.tid AND foltia_station.stationid = foltia_subtitle.stationid  
     196 AND foltia_subtitle.enddatetime >= ?   
     197ORDER BY foltia_subtitle.startdatetime  ASC  
     198LIMIT 1000 
     199        "; 
    180200}//end if 
    181201 
    182 if ($maxrows == 0) { 
     202//$rs = m_query($con, $query, "DBクエリに失敗しました"); 
     203$rs = sql_query($con, $query, "DBクエリに失敗しました",array($now)); 
     204$rowdata = $rs->fetch(); 
     205if (! $rowdata) { 
    183206header("Status: 404 Not Found",TRUE,404); 
    184207printtitle(); 
     
    211234<? 
    212235                /* フィールド数 */ 
    213                $maxcols = pg_num_fields($rs); 
     236    $maxcols = $rs->columnCount(); 
    214237                ?> 
    215238  <table BORDER="0" CELLPADDING="0" CELLSPACING="2" WIDTH="100%"> 
     
    230253                <?php 
    231254                        /* テーブルのデータを出力 */ 
    232                         for ($row = 0; $row < $maxrows; $row++) { /* 行に対応 */ 
    233                                 /* pg_fetch_row で一行取り出す */ 
    234                                 $rowdata = pg_fetch_row($rs, $row); 
    235  
     255     do { 
    236256//他局で同一番組録画済みなら色変え 
    237257if (in_array($rowdata[7], $reservedpidsametid)) { 
     
    283303 
    284304                                echo("</tr>\n"); 
    285                         } 
     305     } while ($rowdata = $rs->fetch()); 
    286306                ?> 
    287307        </tbody> 
  • trunk/install/php/listreserve.php

    r90 r94  
    6262        $query = " 
    6363SELECT 
    64 foltia_program .tid, 
    65 stationname, 
    66 foltia_program .title, 
    67 foltia_subtitle.countno, 
    68 foltia_subtitle.subtitle, 
    69 foltia_subtitle.startdatetime , 
    70 foltia_subtitle.lengthmin , 
    71 foltia_tvrecord.bitrate  ,  
    72 foltia_subtitle.startoffset ,  
    73 foltia_subtitle.pid ,  
    74 foltia_subtitle.epgaddedby ,  
     64 foltia_program.tid, stationname, foltia_program.title, 
     65 foltia_subtitle.countno, foltia_subtitle.subtitle, 
     66 foltia_subtitle.startdatetime as x, foltia_subtitle.lengthmin, 
     67 foltia_tvrecord.bitrate, foltia_subtitle.startoffset, 
     68 foltia_subtitle.pid, foltia_subtitle.epgaddedby, 
    7569foltia_tvrecord.digital  
    7670FROM foltia_subtitle , foltia_program ,foltia_station ,foltia_tvrecord 
    7771WHERE foltia_tvrecord.tid = foltia_program.tid AND foltia_tvrecord.stationid = foltia_station .stationid AND foltia_program.tid = foltia_subtitle.tid AND foltia_station.stationid = foltia_subtitle.stationid 
    78 AND foltia_subtitle.enddatetime >= '$now' 
     72AND foltia_subtitle.enddatetime >= ?  
    7973UNION 
    8074SELECT 
    81 foltia_program .tid, 
    82 stationname, 
    83 foltia_program .title, 
    84 foltia_subtitle.countno, 
    85 foltia_subtitle.subtitle, 
    86 foltia_subtitle.startdatetime , 
    87 foltia_subtitle.lengthmin , 
    88 foltia_tvrecord.bitrate ,  
    89 foltia_subtitle.startoffset ,  
    90 foltia_subtitle.pid ,  
    91 foltia_subtitle.epgaddedby ,  
     75 foltia_program.tid, stationname, foltia_program.title, 
     76 foltia_subtitle.countno, foltia_subtitle.subtitle, 
     77 foltia_subtitle.startdatetime, foltia_subtitle.lengthmin, 
     78 foltia_tvrecord.bitrate,  foltia_subtitle.startoffset, 
     79 foltia_subtitle.pid,  foltia_subtitle.epgaddedby, 
    9280foltia_tvrecord.digital  
    9381FROM foltia_tvrecord 
     
    9684LEFT OUTER JOIN foltia_station on (foltia_subtitle.stationid = foltia_station.stationid ) 
    9785WHERE foltia_tvrecord.stationid = 0 AND 
    98 foltia_subtitle.enddatetime >= '$now' ORDER BY \"startdatetime\" ASC 
     86 foltia_subtitle.enddatetime >= ? ORDER BY x ASC 
    9987        "; 
    10088 
    101         $rs = m_query($con, $query, "DBクエリに失敗しました"); 
    102         $maxrows = pg_num_rows($rs); 
    103                          
     89//      $rs = m_query($con, $query, "DBクエリに失敗しました"); 
     90        $rs = sql_query($con, $query, "DBクエリに失敗しました",array($now,$now)); 
    10491 
    10592//チューナー数 
     
    122109 
    123110<? 
    124         if ($maxrows == 0) { 
     111     $rowdata = $rs->fetch(); 
     112     if (! $rowdata) { 
    125113                print "番組データがありません<BR>\n";                       
    126114                }else{ 
    127  
    128  
    129115                /* フィールド数 */ 
    130                $maxcols = pg_num_fields($rs); 
     116             $maxcols = $rs->columnCount(); 
    131117                ?> 
    132118  <table BORDER="0" CELLPADDING="0" CELLSPACING="2" WIDTH="100%"> 
     
    149135                <?php 
    150136                        /* テーブルのデータを出力 */ 
    151                        for ($row = 0; $row < $maxrows; $row++) { /* 行に対応 */ 
     137                  do { 
    152138                                echo("<tr>\n"); 
    153                                 /* pg_fetch_row で一行取り出す */ 
    154                                 $rowdata = pg_fetch_row($rs, $row); 
     139 
    155140$pid = htmlspecialchars($rowdata[9]); 
    156141 
     
    168153$query = " 
    169154SELECT 
    170 foltia_program .tid, 
    171 stationname, 
    172 foltia_program .title, 
    173 foltia_subtitle.countno, 
    174 foltia_subtitle.subtitle, 
    175 foltia_subtitle.startdatetime , 
    176 foltia_subtitle.lengthmin , 
    177 foltia_tvrecord.bitrate  ,  
    178 foltia_subtitle.startoffset ,  
    179 foltia_subtitle.pid  ,  
    180 foltia_tvrecord.digital  
     155 foltia_program.tid, stationname, foltia_program.title, 
     156 foltia_subtitle.countno, foltia_subtitle.subtitle, 
     157 foltia_subtitle.startdatetime, foltia_subtitle.lengthmin, 
     158 foltia_tvrecord.bitrate, foltia_subtitle.startoffset, 
     159 foltia_subtitle.pid, foltia_tvrecord.digital 
    181160FROM foltia_subtitle , foltia_program ,foltia_station ,foltia_tvrecord 
    182161WHERE foltia_tvrecord.tid = foltia_program.tid AND foltia_tvrecord.stationid = foltia_station .stationid AND foltia_program.tid = foltia_subtitle.tid AND foltia_station.stationid = foltia_subtitle.stationid 
    183 AND foltia_subtitle.enddatetime > '$rowdata[5]'  
    184 AND foltia_subtitle.startdatetime < '$endtime'   
     162AND foltia_subtitle.enddatetime > ?  
     163AND foltia_subtitle.startdatetime < ?   
    185164UNION 
    186165SELECT 
    187 foltia_program .tid, 
    188 stationname, 
    189 foltia_program .title, 
    190 foltia_subtitle.countno, 
    191 foltia_subtitle.subtitle, 
    192 foltia_subtitle.startdatetime , 
    193 foltia_subtitle.lengthmin , 
    194 foltia_tvrecord.bitrate  ,  
    195 foltia_subtitle.startoffset ,  
    196 foltia_subtitle.pid ,  
    197 foltia_tvrecord.digital  
     166 foltia_program.tid, stationname, foltia_program.title, 
     167 foltia_subtitle.countno, foltia_subtitle.subtitle, 
     168 foltia_subtitle.startdatetime, foltia_subtitle.lengthmin, 
     169 foltia_tvrecord.bitrate, foltia_subtitle.startoffset, 
     170 foltia_subtitle.pid, foltia_tvrecord.digital 
    198171FROM foltia_tvrecord 
    199172LEFT OUTER JOIN foltia_subtitle on (foltia_tvrecord.tid = foltia_subtitle.tid ) 
     
    201174LEFT OUTER JOIN foltia_station on (foltia_subtitle.stationid = foltia_station.stationid ) 
    202175WHERE foltia_tvrecord.stationid = 0 AND 
    203 foltia_subtitle.enddatetime > '$rowdata[5]'   
    204 AND foltia_subtitle.startdatetime < '$endtime'   
    205        "; 
     176foltia_subtitle.enddatetime > ?   
     177AND foltia_subtitle.startdatetime < ?   
     178"; 
    206179        $rclass = ""; 
    207         $overlap = m_query($con, $query, "DBクエリに失敗しました"); 
    208         $overlapmaxrows = pg_num_rows($overlap); 
     180//      $overlap = m_query($con, $query, "DBクエリに失敗しました"); 
     181        $overlap = sql_query($con, $query, "DBクエリに失敗しました",array($rowdata[5],$endtime,$rowdata[5],$endtime)); 
     182                          $owrowall = $overlap->fetchAll(); 
     183                          $overlapmaxrows = count($owrowall); 
    209184        if ($overlapmaxrows > ($recunits) ){ 
    210185                 
     
    212187                 
    213188                for ($rrow = 0; $rrow < $overlapmaxrows ; $rrow++) { 
    214                         $owrowdata = pg_fetch_array($overlap, $rrow)
     189                                         $owrowdata = $owrowall[$rrow]
    215190                        $owtimeline[ $owrowdata['startdatetime'] ] = $owtimeline[ $owrowdata['startdatetime'] ] +1; 
    216191                         
     
    237212$query = " 
    238213SELECT 
    239 foltia_program .tid, 
    240 stationname, 
    241 foltia_program .title, 
    242 foltia_subtitle.countno, 
    243 foltia_subtitle.subtitle, 
    244 foltia_subtitle.startdatetime , 
    245 foltia_subtitle.lengthmin , 
    246 foltia_tvrecord.bitrate  ,  
    247 foltia_subtitle.startoffset ,  
    248 foltia_subtitle.pid  ,  
    249 foltia_tvrecord.digital  
     214 foltia_program.tid, stationname, foltia_program.title, 
     215 foltia_subtitle.countno, foltia_subtitle.subtitle, 
     216 foltia_subtitle.startdatetime, foltia_subtitle.lengthmin, 
     217 foltia_tvrecord.bitrate, foltia_subtitle.startoffset, 
     218 foltia_subtitle.pid, foltia_tvrecord.digital 
    250219FROM foltia_subtitle , foltia_program ,foltia_station ,foltia_tvrecord 
    251220WHERE foltia_tvrecord.tid = foltia_program.tid AND foltia_tvrecord.stationid = foltia_station .stationid AND foltia_program.tid = foltia_subtitle.tid AND foltia_station.stationid = foltia_subtitle.stationid 
    252 AND foltia_subtitle.enddatetime > '$rowdata[5]'  
    253 AND foltia_subtitle.startdatetime < '$endtime'   
     221AND foltia_subtitle.enddatetime > ?  
     222AND foltia_subtitle.startdatetime < ?   
    254223AND  (foltia_station.stationrecch = '0' OR  foltia_station.stationrecch = '-1' )  
    255224UNION 
    256225SELECT 
    257 foltia_program .tid, 
    258 stationname, 
    259 foltia_program .title, 
    260 foltia_subtitle.countno, 
    261 foltia_subtitle.subtitle, 
    262 foltia_subtitle.startdatetime , 
    263 foltia_subtitle.lengthmin , 
    264 foltia_tvrecord.bitrate  ,  
    265 foltia_subtitle.startoffset ,  
    266 foltia_subtitle.pid ,  
    267 foltia_tvrecord.digital  
     226 foltia_program.tid, stationname, foltia_program.title, 
     227 foltia_subtitle.countno, foltia_subtitle.subtitle, 
     228 foltia_subtitle.startdatetime, foltia_subtitle.lengthmin, 
     229 foltia_tvrecord.bitrate, foltia_subtitle.startoffset, 
     230 foltia_subtitle.pid, foltia_tvrecord.digital 
    268231FROM foltia_tvrecord 
    269232LEFT OUTER JOIN foltia_subtitle on (foltia_tvrecord.tid = foltia_subtitle.tid ) 
     
    271234LEFT OUTER JOIN foltia_station on (foltia_subtitle.stationid = foltia_station.stationid ) 
    272235WHERE foltia_tvrecord.stationid = 0 AND 
    273 foltia_subtitle.enddatetime > '$rowdata[5]'   
    274 AND foltia_subtitle.startdatetime < '$endtime'   
     236foltia_subtitle.enddatetime > ?   
     237AND foltia_subtitle.startdatetime < ?   
    275238AND  (foltia_station.stationrecch = '0' OR  foltia_station.stationrecch = '-1' )  
    276  
    277239        "; 
    278         $eoverlap = m_query($con, $query, "DBクエリに失敗しました"); 
    279         $eoverlapmaxrows = pg_num_rows($eoverlap); 
     240//      $eoverlap = m_query($con, $query, "DBクエリに失敗しました"); 
     241        $eoverlap = sql_query($con, $query, "DBクエリに失敗しました",array($rowdata[5], $endtime,$rowdata[5],  $endtime)); 
     242                          $eowrowall = $eoverlap->fetchAll(); 
     243                          $eoverlapmaxrows = count($eowrowall); 
    280244        if ($eoverlapmaxrows > ($externalinputs) ){ 
    281245                 
     
    283247                 
    284248                for ($erow = 0; $erow < $eoverlapmaxrows ; $erow++) { 
    285                         $eowrowdata = pg_fetch_array($eoverlap, $erow)
     249                                         $eowrowdata = $eowrowall[$erow]
    286250                        $eowtimeline[ $eowrowdata['startdatetime'] ] = $eowtimeline[ $eowrowdata['startdatetime'] ] +1; 
    287251                         
     
    359323                                        echo("<br></td>\n"); 
    360324                                echo("</tr>\n"); 
    361                        } 
     325                  } while ($rowdata = $rs->fetch()); 
    362326                ?> 
    363327        </tbody> 
     
    374338 
    375339<?php 
    376 } //if ($maxrows == 0) { 
    377  
    378  
     340    } //if ($maxrows == 0) 
    379341        $query = " 
    380342SELECT  
    381 foltia_program.tid, 
    382 stationname, 
    383 foltia_program .title , 
    384 foltia_tvrecord.bitrate , 
    385 foltia_tvrecord.stationid ,  
     343 foltia_program.tid, stationname, foltia_program.title, 
     344 foltia_tvrecord.bitrate, foltia_tvrecord.stationid,  
    386345foltia_tvrecord.digital    
    387346FROM  foltia_tvrecord , foltia_program , foltia_station  
     
    389348ORDER BY foltia_program.tid  DESC 
    390349"; 
    391       $rs = m_query($con, $query, "DBクエリに失敗しました"); 
    392         $maxrows = pg_num_rows($rs); 
    393                        
    394                if ($maxrows == 0) { 
     350//    $rs = m_query($con, $query, "DBクエリに失敗しました"); 
     351        $rs = sql_query($con, $query, "DBクエリに失敗しました"); 
     352$rowdata = $rs->fetch();                       
     353if (! $rowdata) { 
    395354//なければなにもしない 
    396355                         
    397356                }else{ 
    398                $maxcols = pg_num_fields($rs); 
     357        $maxcols = $rs->columnCount(); 
    399358 
    400359?> 
     
    417376                <?php 
    418377                        /* テーブルのデータを出力 */ 
    419                         for ($row = 0; $row < $maxrows; $row++) { /* 行に対応 */ 
    420                                 /* pg_fetch_row で一行取り出す */ 
    421                                 $rowdata = pg_fetch_row($rs, $row); 
    422  
     378             do { 
    423379                                $tid = htmlspecialchars($rowdata[0]); 
    424380                                 
     
    468424                                echo("\n</tr>"); 
    469425                                }//if tid 0 
    470                        }//for 
     426             } while ($rowdata = $rs->fetch()); 
    471427                }//else 
    472428                ?> 
  • trunk/install/php/m.php

    r83 r94  
    9797SELECT stationname   
    9898FROM foltia_station  
    99 WHERE stationid = $recstid"; 
    100         $stationvalid = m_query($con, $query, "DBクエリに失敗しました"); 
    101         $stationcount = pg_num_rows($stationvalid); 
    102  
    103         if ($stationcount == 1){ 
    104                 $recstationname = pg_fetch_row($stationvalid, 0); 
    105         //valid 
    106         }else{ 
     99WHERE stationid = ? "; 
     100//      $stationvalid = m_query($con, $query, "DBクエリに失敗しました"); 
     101        $stationvalid = sql_query($con, $query, "DBクエリに失敗しました",array($recstid)); 
     102                $recstationname = $stationvalid->fetch(); 
     103                if (! $recstationname) { 
    107104                $errflag = 3; 
    108105                $errmsg = "放送局設定が異常です。"; 
     
    128125//min pidを探す 
    129126$query = "SELECT min(pid) FROM  foltia_subtitle "; 
    130         $rs = m_query($con, $query, "DBクエリに失敗しました"); 
    131         $maxrows = pg_num_rows($rs); 
    132         if ($maxrows == 0){ 
    133         $insertpid = -1 ; 
     127//      $rs = m_query($con, $query, "DBクエリに失敗しました"); 
     128        $rs = sql_query($con, $query, "DBクエリに失敗しました"); 
     129        $rowdata = $rs->fetch(); 
     130        if (! $rowdata) { 
     131                $insertpid = -1 ; 
    134132        }else{ 
    135         $rowdata = pg_fetch_row($rs, 0); 
    136         $insertpid = $rowdata[0]; 
    137         $insertpid-- ; 
     133                if ($rowdata[0] > 0) { 
     134                        $insertpid = -1 ; 
     135                }else{ 
     136                        $insertpid = $rowdata[0]; 
     137                        $insertpid-- ; 
     138                } 
    138139        } 
    139140// next 話数を探す 
    140141$query = "SELECT max(countno) FROM  foltia_subtitle WHERE tid = 0"; 
    141         $rs = m_query($con, $query, "DBクエリに失敗しました"); 
    142         $maxrows = pg_num_rows($rs); 
    143         if ($maxrows == 0){ 
     142//      $rs = m_query($con, $query, "DBクエリに失敗しました"); 
     143        $rs = sql_query($con, $query, "DBクエリに失敗しました"); 
     144                        $rowdata = $rs->fetch(); 
     145                        if (! $rowdata) { 
    144146        $nextcno = 1 ; 
    145147        }else{ 
    146         $rowdata = pg_fetch_row($rs, 0); 
    147148        $nextcno = $rowdata[0]; 
    148149        $nextcno++ ; 
     
    159160        insert into foltia_subtitle  (pid ,tid ,stationid , countno ,subtitle , 
    160161startdatetime ,enddatetime ,startoffset , lengthmin , epgaddedby )   
    161         values ( '$insertpid','0','$recstid', 
    162                 '$nextcno','$pname','$startdatetime','$enddatetime','0' ,'$lengthmin', '$memberid')"; 
     162        values ( ?,'0',?,?,?,?,?,'0',?,?)"; 
    163163         
    164                 $rs = m_query($con, $query, "DBクエリに失敗しました"); 
     164//              $rs = m_query($con, $query, "DBクエリに失敗しました"); 
     165//print "【DEBUG】$insertpid,$recstid,$nextcno,$pname,$startdatetime,$enddatetime ,$lengthmin,$memberid <br>\n"; 
     166                $rs = sql_query($con, $query, "DBクエリに失敗しました",array($insertpid,$recstid,$nextcno,$pname,$startdatetime,$enddatetime ,$lengthmin,$memberid)); 
    165167         
    166168        //addatq.pl 
     
    168170        //引数 TID チャンネルID 
    169171        //echo("$toolpath/perl/addatq.pl $tid $station"); 
    170          
    171                 $oserr = system("$toolpath/perl/addatq.pl 0 0"); 
     172        exec("$toolpath/perl/addatq.pl 0 0"); 
     173        $oserr = system("$toolpath/perl/addatq.pl 0 0"); 
     174        //--------------------------------------------------- 
     175                        if ($oserr){ 
     176                        print "[DEBUG]$oserr 「$toolpath/perl/addatq.pl 0 0」<br>\n"; 
     177                }else{ 
     178                        print "[DEBUG]exec addatq.pl false 「$toolpath/perl/addatq.pl 0 0」<br>\n"; 
     179                         
     180                        $oserr = system("$toolpath/perl/perltestscript.pl"); 
     181                        if ($oserr){ 
     182                                print "[DEBUG]exec perltestscript.pl $oserr<br>\n"; 
     183                        }else{ 
     184                                print "[DEBUG]exec perltestscript.pl false <br>\n"; 
     185                        } 
     186                         
     187                } 
     188        //----------------------------------------------------- 
    172189        }else{ 
    173190                print "EPG予約を行う権限がありません。"; 
     
    200217}// 初回表示かデータ処理か 
    201218?> 
    202 <form id="record" name="record" method="get" action="./m.php"
     219<form id="record" name="record" method="get" action="./m.php" autocomplete="off"
    203220  <p>放送日: 
    204221    <input name="startdate" type="text" id="startdate" size="9" value="<?=$startdate?>" /> 
     
    215232<?php 
    216233$query = " 
    217 SELECT stationid,stationname,stationrecch ,digitalch  
     234SELECT stationid as x, stationname, stationrecch, digitalch  
    218235FROM foltia_station  
    219236WHERE stationrecch > 0  
     
    221238SELECT DISTINCT  stationid,stationname,stationrecch ,digitalch  
    222239FROM  foltia_station  
    223 WHERE digitalch > 0 
    224 ORDER BY \"stationid\" ASC"; 
    225  
    226         $stations = m_query($con, $query, "DBクエリに失敗しました"); 
    227         $stationcount = pg_num_rows($stations); 
    228          
    229 if ($stationcount > 0 ){ 
    230         for ($row = 0; $row < $stationcount ; $row++) { 
    231                 $rowdata = pg_fetch_row($stations, $row); 
     240WHERE digitalch > 0  
     241ORDER BY x ASC"; 
     242 
     243$stations = sql_query($con, $query, "DBクエリに失敗しました"); 
     244$rowdata = $stations->fetch(); 
     245 
     246if ($rowdata) { 
     247                           do { 
    232248                        if ($recstid == $rowdata[0]){ 
    233                         print " <input name=\"recstid\" type=\"radio\" value=\"$rowdata[0]\" checked />  $rowdata[1] ($rowdata[2]ch) \n"; 
     249                        print " <input name=\"recstid\" type=\"radio\" value=\"$rowdata[0]\" checked />  $rowdata[1] ($rowdata[2]ch / $rowdata[3]ch) \n"; 
    234250                        }else{ 
    235                                 print " <input name=\"recstid\" type=\"radio\" value=\"$rowdata[0]\" />  $rowdata[1] ($rowdata[2]ch) \n"; 
     251                                print " <input name=\"recstid\" type=\"radio\" value=\"$rowdata[0]\" />  $rowdata[1] ($rowdata[2]ch / $rowdata[3]ch) \n"; 
    236252                        } 
    237         } 
     253                          } while ($rowdata = $stations->fetch()); 
    238254}else{ 
    239255print "放送局データベースが正しくセットアップされていません。録画可能局がありません"; 
    240256} 
    241  
     257//外部入力チャンネル 
    242258$query = " 
    243 SELECT stationid,stationname,stationrecch  
     259SELECT stationid as x ,stationname,stationrecch  
    244260FROM foltia_station  
    245261WHERE stationrecch > -2 AND stationrecch < 1  
    246 ORDER BY \"stationid\" ASC"; 
    247  
    248         $stations = m_query($con, $query, "DBクエリに失敗しました"); 
    249         $stationcount = pg_num_rows($stations); 
    250          
    251 if ($stationcount > 0 ){ 
    252         for ($row = 0; $row < $stationcount ; $row++) { 
    253                 $rowdata = pg_fetch_row($stations, $row); 
     262ORDER BY x ASC"; 
     263 
     264//      $stations = m_query($con, $query, "DBクエリに失敗しました"); 
     265        $stations = sql_query($con, $query, "DBクエリに失敗しました"); 
     266$rowdata = $stations->fetch();   
     267if ($rowdata) { 
     268        do { 
    254269                if ($rowdata[0] != 0){ 
    255270                        if ($recstid == $rowdata[0]){ 
     
    260275 
    261276                } 
    262         } 
     277        } while ($rowdata = $stations->fetch()); 
    263278} 
    264279/* 
  • trunk/install/php/reservecomp.php

    r83 r94  
    6767 
    6868//タイトル取得 
    69         $query = "select title from foltia_program where tid='$tid'"; 
    70       $rs = m_query($con, $query, "DBクエリに失敗しました"); 
    71         $maxrows = pg_num_rows($rs); 
    72                          
    73                if ($maxrows == 0) { 
     69        $query = "select title from foltia_program where tid = ? "; 
     70//    $rs = m_query($con, $query, "DBクエリに失敗しました"); 
     71        $rs = sql_query($con, $query, "DBクエリに失敗しました",array($tid)); 
     72$rowdata = $rs->fetch(); 
     73if (! $rowdata) { 
    7474                $title = "(未登録)"; 
    7575                }else{ 
    76                 $rowdata = pg_fetch_row($rs, 0); 
    7776                $title = htmlspecialchars($rowdata[0]); 
    7877                } 
     
    130129} 
    131130        $rs = m_query($con, $query, "DBクエリに失敗しました"); 
    132         $maxrows = pg_num_rows($rs); 
    133                          
    134                 if ($maxrows == 0) { 
     131$rowdata = $rs->fetch(); 
     132if (! $rowdata) { 
    135133                echo("放映予定はいまのところありません<BR>"); 
    136134                } 
    137135                else{ 
    138                $maxcols = pg_num_fields($rs);           
     136        $maxcols = $rs->columnCount(); 
    139137?> 
    140138  <table BORDER="0" CELLPADDING="0" CELLSPACING="2" WIDTH="100%" BGCOLOR="#bcf1be"> 
     
    155153                <?php 
    156154                        /* テーブルのデータを出力 */ 
    157                         for ($row = 0; $row < $maxrows; $row++) { /* 行に対応 */ 
     155       do { 
    158156                                echo("<tr>\n"); 
    159                                 /* pg_fetch_row で一行取り出す */ 
    160                                 $rowdata = pg_fetch_row($rs, $row); 
    161  
    162157                                for ($col = 0; $col < $maxcols; $col++) { /* 列に対応 */ 
    163158                                        echo("<td>".htmlspecialchars($rowdata[$col])."<br></td>\n"); 
    164159                                } 
    165160                                echo("</tr>\n"); 
    166                         } 
     161       } while ($rowdata = $rs->fetch()); 
    167162                }//end if 
    168163                ?> 
     
    177172//既存が予約あって、新着が全局予約だったら 
    178173if ($station ==0){ 
    179         $query = " 
    180 SELECT  
    181  *  
    182 FROM foltia_tvrecord   
    183 WHERE tid = '$tid'  
    184 "; 
    185         $rs = m_query($con, $query, "DBクエリに失敗しました"); 
    186         $maxrows = pg_num_rows($rs); 
    187         if ($maxrows > 0){ 
    188174        //既存局を消す 
    189175                $query = "DELETE  
    190176FROM foltia_tvrecord   
    191 WHERE tid = '$tid'  
    192 "; 
    193       $rs = m_query($con, $query, "DBクエリに失敗しました"); 
    194                } 
     177WHERE tid = ?  
     178"; 
     179//    $rs = m_query($con, $query, "DBクエリに失敗しました"); 
     180        $rs = sql_query($con, $query, "DBクエリに失敗しました",array($tid)); 
    195181}//endif 
    196182 
    197183        $query = " 
    198184SELECT  
    199  *  
     185count(*)  
    200186FROM foltia_tvrecord   
    201 WHERE tid = '$tid'  AND stationid = '$station'  
    202 "; 
    203       $rs = m_query($con, $query, "DBクエリに失敗しました"); 
    204         $maxrows = pg_num_rows($rs); 
    205  
     187WHERE tid = ?  AND stationid = ?  
     188"; 
     189//    $rs = m_query($con, $query, "DBクエリに失敗しました"); 
     190        $rs = sql_query($con, $query, "DBクエリに失敗しました",array($tid,$station)); 
     191        $maxrows = $rs->fetchColumn(0); 
    206192                if ($maxrows == 0) { //新規追加 
    207                                 $query = "INSERT INTO  foltia_tvrecord  values ('$tid','$station','$bitrate','$usedigital')"; 
    208                                 $rs = m_query($con, $query, "DB書き込みに失敗しました"); 
     193                                $query = "INSERT INTO  foltia_tvrecord  values (?,?,?,?)"; 
     194//                              $rs = m_query($con, $query, "DB書き込みに失敗しました"); 
     195                                $rs = sql_query($con, $query, "DB書き込みに失敗しました",array($tid,$station,$bitrate,$usedigital)); 
    209196                }else{//修正 (ビットレート) 
    210197                        $query = "UPDATE  foltia_tvrecord  SET  
    211   bitrate = '$bitrate' , digital = '$usedigital'  WHERE tid = '$tid'  AND stationid = '$station' "; 
    212                         $rs = m_query($con, $query, "DB書き込みに失敗しました"); 
     198  bitrate = ? , digital = ? WHERE tid = ? AND stationid = ? "; 
     199//                      $rs = m_query($con, $query, "DB書き込みに失敗しました"); 
     200                        $rs = sql_query($con, $query, "DB書き込みに失敗しました",array( $bitrate, $usedigital , $tid , $station )); 
    213201                } 
    214202         
  • trunk/install/php/reserveepg.php

    r70 r94  
    5656        stationname , stationrecch ,stationid  
    5757        FROM foltia_epg , foltia_station  
    58         WHERE epgid='$epgid' AND foltia_station.ontvcode = foltia_epg.ontvchannel 
     58        WHERE epgid = ? AND foltia_station.ontvcode = foltia_epg.ontvchannel 
    5959        ";//4812 
    60       $rs = m_query($con, $query, "DBクエリに失敗しました"); 
    61         $maxrows = pg_num_rows($rs); 
    62                          
    63                if ($maxrows == 0) { 
     60//    $rs = m_query($con, $query, "DBクエリに失敗しました"); 
     61        $rs = sql_query($con, $query, "DBクエリに失敗しました",array($epgid)); 
     62$rowdata = $rs->fetch(); 
     63if (! $rowdata) { 
    6464                die_exit("登録番組がありません<BR>"); 
    6565                } 
    66                 $rowdata = pg_fetch_row($rs, 0); 
     66 
    6767                //$title = htmlspecialchars($rowdata[0]); 
    6868?> 
     
    136136$query = " 
    137137SELECT 
    138 foltia_program .title, 
    139 foltia_program .tid, 
    140 stationname, 
    141 foltia_station.stationid ,   
    142 foltia_subtitle.countno, 
    143 foltia_subtitle.subtitle, 
    144 foltia_subtitle.startdatetime , 
    145 foltia_subtitle.lengthmin , 
    146 foltia_tvrecord.bitrate  ,  
    147 foltia_subtitle.startoffset ,  
    148 foltia_subtitle.pid   
     138 foltia_program.title, foltia_program.tid, stationname, 
     139 foltia_station.stationid, foltia_subtitle.countno, 
     140 foltia_subtitle.subtitle, foltia_subtitle.startdatetime, 
     141 foltia_subtitle.lengthmin, foltia_tvrecord.bitrate, 
     142 foltia_subtitle.startoffset, foltia_subtitle.pid 
    149143FROM foltia_subtitle , foltia_program ,foltia_station ,foltia_tvrecord 
    150144WHERE foltia_tvrecord.tid = foltia_program.tid AND foltia_tvrecord.stationid = foltia_station .stationid AND foltia_program.tid = foltia_subtitle.tid AND foltia_station.stationid = foltia_subtitle.stationid 
    151 AND foltia_subtitle.startdatetime ='$startfoltime'  
    152 AND foltia_subtitle.enddatetime = '$endfoltime'  
    153 AND foltia_station.stationid = '$stationid'   
     145AND foltia_subtitle.startdatetime = ?  
     146AND foltia_subtitle.enddatetime = ?  
     147AND foltia_station.stationid = ?  
    154148UNION 
    155149SELECT 
    156 foltia_program .title, 
    157 foltia_program .tid, 
    158 stationname, 
    159 foltia_station.stationid ,   
    160 foltia_subtitle.countno, 
    161 foltia_subtitle.subtitle, 
    162 foltia_subtitle.startdatetime , 
    163 foltia_subtitle.lengthmin , 
    164 foltia_tvrecord.bitrate ,  
    165 foltia_subtitle.startoffset ,  
    166 foltia_subtitle.pid   
     150 foltia_program.title, foltia_program.tid, stationname, 
     151 foltia_station.stationid, foltia_subtitle.countno, 
     152 foltia_subtitle.subtitle, foltia_subtitle.startdatetime, 
     153 foltia_subtitle.lengthmin, foltia_tvrecord.bitrate, 
     154 foltia_subtitle.startoffset, foltia_subtitle.pid 
    167155FROM foltia_tvrecord 
    168156LEFT OUTER JOIN foltia_subtitle on (foltia_tvrecord.tid = foltia_subtitle.tid ) 
     
    170158LEFT OUTER JOIN foltia_station on (foltia_subtitle.stationid = foltia_station.stationid ) 
    171159WHERE foltia_tvrecord.stationid = 0  
    172 AND foltia_subtitle.startdatetime ='$startfoltime'  
    173 AND foltia_subtitle.enddatetime = '$endfoltime'  
    174 AND foltia_station.stationid = '$stationid'  
     160AND foltia_subtitle.startdatetime = ?  
     161AND foltia_subtitle.enddatetime = ?  
     162AND foltia_station.stationid = ?  
    175163"; 
    176164 
    177  
    178  
    179         $rs = m_query($con, $query, "DBクエリに失敗しました"); 
    180         $maxrows = pg_num_rows($rs); 
    181  
    182165//print "<!--$query \n $maxrows\n -->"; 
    183166 
    184167print "<form name=\"recordingsetting\" method=\"POST\" action=\"reserveepgcomp.php\">\n"; 
    185168 
    186                 if ($maxrows == 0) { 
     169//$rs = m_query($con, $query, "DBクエリに失敗しました"); 
     170$rs = sql_query($con, $query, "DBクエリに失敗しました",array($startfoltime,$endfoltime,$stationid,$startfoltime,$endfoltime,$stationid)); 
     171$chkoverwrap = $rs->fetch(); 
     172if (! $chkoverwrap) { 
    187173                //重複なし 
    188174                print "<input type=\"submit\" value=\"予約\" ><br>\n"; 
    189175                }else{ 
    190                 $chkoverwrap = pg_fetch_row($rs, 0); 
    191176                $prereservedtitle = htmlspecialchars($chkoverwrap[0]); 
    192177                $tid =  htmlspecialchars($chkoverwrap[1]); 
  • trunk/install/php/reserveepgcomp.php

    r83 r94  
    7272//min pidを探す 
    7373$query = "SELECT min(pid) FROM  foltia_subtitle "; 
    74         $rs = m_query($con, $query, "DBクエリに失敗しました"); 
    75         $maxrows = pg_num_rows($rs); 
    76         if ($maxrows == 0){ 
     74//      $rs = m_query($con, $query, "DBクエリに失敗しました"); 
     75        $rs = sql_query($con, $query, "DBクエリに失敗しました"); 
     76        $rowdata = $rs->fetch(); 
     77        if (! $rowdata) { 
    7778        $insertpid = -1 ; 
    7879        }else{ 
    79         $rowdata = pg_fetch_row($rs, 0); 
    80          
    8180        $insertpid = $rowdata[0]; 
    8281                if ($insertpid > 0){ 
     
    8887// next 話数を探す 
    8988$query = "SELECT max(countno) FROM  foltia_subtitle WHERE tid = 0"; 
    90         $rs = m_query($con, $query, "DBクエリに失敗しました"); 
    91         $maxrows = pg_num_rows($rs); 
    92         if ($maxrows == 0){ 
     89//      $rs = m_query($con, $query, "DBクエリに失敗しました"); 
     90        $rs = sql_query($con, $query, "DBクエリに失敗しました"); 
     91        $rowdata = $rs->fetch(); 
     92        if (! $rowdata) { 
    9393        $nextcno = 1 ; 
    9494        }else{ 
    95         $rowdata = pg_fetch_row($rs, 0); 
    9695        $nextcno = $rowdata[0]; 
    9796        $nextcno++ ; 
     
    124123insert into foltia_subtitle  (pid ,tid ,stationid , countno ,subtitle , 
    125124startdatetime ,enddatetime ,startoffset , lengthmin , epgaddedby )  
    126 values ( '$insertpid','0','$stationid', 
    127        '$nextcno','$subtitle','$startdatetime','$enddatetime','0' ,'$lengthmin' , '$memberid')"
    128         $rs = m_query($con, $query, "DBクエリに失敗しました"); 
     125values ( ?,'0',?,?,?,?,?,'0',?,?)"; 
     126//     $rs = m_query($con, $query, "DBクエリに失敗しました")
     127        $rs = sql_query($con, $query, "DBクエリに失敗しました",array($insertpid,$stationid,$nextcno,$subtitle,$startdatetime,$enddatetime,$lengthmin,$memberid)); 
    129128 
    130129        //addatq.pl 
  • trunk/install/php/reserveprogram.php

    r83 r94  
    5353 
    5454//タイトル取得 
    55         $query = "select title from foltia_program where tid='$tid'"; 
    56       $rs = m_query($con, $query, "DBクエリに失敗しました"); 
    57        $maxrows = pg_num_rows($rs); 
    58                          
    59                if ($maxrows == 0) { 
     55        $query = "select title from foltia_program where tid = ? "; 
     56//    $rs = m_query($con, $query, "DBクエリに失敗しました"); 
     57$rs = sql_query($con, $query, "DBクエリに失敗しました",array($tid)); 
     58$rowdata = $rs->fetch(); 
     59if (! $rowdata) { 
    6060                die_exit("登録番組がありません<BR>"); 
    6161                } 
    62                 $rowdata = pg_fetch_row($rs, 0); 
     62 
    6363                $title = htmlspecialchars($rowdata[0]); 
    6464?> 
     
    100100FROM foltia_subtitle , foltia_program ,foltia_station   
    101101WHERE foltia_program.tid = foltia_subtitle.tid AND foltia_station.stationid = foltia_subtitle.stationid  
    102  AND foltia_program.tid ='$tid'  
     102 AND foltia_program.tid = ?  
    103103ORDER BY stationrecch DESC 
    104104"; 
    105  
    106         $rs = m_query($con, $query, "DBクエリに失敗しました"); 
    107         $maxrows = pg_num_rows($rs); 
    108                          
    109                 if ($maxrows == 0) { 
     105//      $rs = m_query($con, $query, "DBクエリに失敗しました"); 
     106$rs = sql_query($con, $query, "DBクエリに失敗しました",array($tid)); 
     107$rowdata = $rs->fetch(); 
     108if (! $rowdata) { 
    110109                echo("放映局情報がまだはいってません<BR>"); 
    111110                } 
    112111                else{ 
    113                $maxcols = pg_num_fields($rs); 
     112        $maxcols = $rs->columnCount(); 
    114113                 
    115114                        echo("<select name=\"station\">\n"); 
    116115                        /* テーブルのデータを出力 */ 
    117                         for ($row = 0; $row < $maxrows; $row++) { /* 行に対応 */ 
    118                                 /* pg_fetch_row で一行取り出す */ 
    119                                 $rowdata = pg_fetch_row($rs, $row); 
     116        do { 
    120117                                echo("<option value=\""); 
    121118                                echo(htmlspecialchars($rowdata[0])); 
     
    123120                                echo(htmlspecialchars($rowdata[1])); 
    124121                                echo("</option>\n"); 
    125                        }//for 
     122        } while ($rowdata = $rs->fetch()); 
    126123                        echo("<option value=\"0\">全局</option>\n</select>\n"); 
    127124                }//endif                 
     
    182179FROM foltia_subtitle , foltia_program ,foltia_station   
    183180WHERE foltia_program.tid = foltia_subtitle.tid AND foltia_station.stationid = foltia_subtitle.stationid  
    184  AND foltia_subtitle.startdatetime >= '$now'  AND foltia_program.tid ='$tid'  
     181 AND foltia_subtitle.startdatetime >= ?  AND foltia_program.tid = ?  
    185182ORDER BY foltia_subtitle.startdatetime  ASC 
    186183"; 
    187       $rs = m_query($con, $query, "DBクエリに失敗しました"); 
    188        $maxrows = pg_num_rows($rs); 
    189                          
    190                if ($maxrows == 0) { 
     184//    $rs = m_query($con, $query, "DBクエリに失敗しました"); 
     185$rs = sql_query($con, $query, "DBクエリに失敗しました",array($now,$tid)); 
     186$rowdata = $rs->fetch(); 
     187if (! $rowdata) { 
    191188                echo("放映予定はありません<BR>"); 
    192189                } 
    193190                else{ 
    194                $maxcols = pg_num_fields($rs);           
     191        $maxcols = $rs->columnCount(); 
    195192?> 
    196193  <table BORDER="0" CELLPADDING="0" CELLSPACING="2" WIDTH="100%" BGCOLOR="#bcf1be"> 
     
    210207                <?php 
    211208                        /* テーブルのデータを出力 */ 
    212                         for ($row = 0; $row < $maxrows; $row++) { /* 行に対応 */ 
     209       do { 
    213210                                echo("<tr>\n"); 
    214                                 /* pg_fetch_row で一行取り出す */ 
    215                                 $rowdata = pg_fetch_row($rs, $row); 
    216  
    217211                                for ($col = 0; $col < $maxcols; $col++) { /* 列に対応 */ 
    218212                                        if ($col == 3){ 
     
    223217                                } 
    224218                                echo("</tr>\n"); 
    225                         } 
     219       } while ($rowdata = $rs->fetch()); 
    226220                }//end if 
    227221                ?> 
  • trunk/install/php/selectcaptureimage.php

    r85 r94  
    7474FROM foltia_subtitle , foltia_program ,foltia_station   
    7575WHERE foltia_program.tid = foltia_subtitle.tid AND foltia_station.stationid = foltia_subtitle.stationid  
    76  AND foltia_subtitle.pid = '$pid'   
     76 AND foltia_subtitle.pid = ?   
    7777  
    7878        "; 
    79         $rs = m_query($con, $query, "DBクエリに失敗しました"); 
    80 $rows = pg_num_rows($rs); 
    81 if ($rows == 0){ 
     79//      $rs = m_query($con, $query, "DBクエリに失敗しました"); 
     80$rs = sql_query($con, $query, "DBクエリに失敗しました",array($pid)); 
     81$rowdata = $rs->fetch(); 
     82if (! $rowdata) { 
    8283        print "  <p align=\"left\"><font color=\"#494949\" size=\"6\">キャプチャ画像</font></p> 
    8384  <hr size=\"4\"> 
     
    8788 
    8889}else{ 
    89 $rowdata = pg_fetch_row($rs, 0); 
    90  
    9190print "  <p align=\"left\"><font color=\"#494949\" size=\"6\">キャプチャ画像</font></p> 
    9291  <hr size=\"4\"> 
  • trunk/install/php/showlib.php

    r83 r94  
    8484"; 
    8585 
    86 $rs = m_query($con, $query, "DBクエリに失敗しました"); 
    87  
    88 $maxrows = pg_num_rows($rs); 
    89  
    90 if ($maxrows > 0 ){ 
     86//$rs = m_query($con, $query, "DBクエリに失敗しました"); 
     87$rs = sql_query($con, $query, "DBクエリに失敗しました"); 
     88$rowdata = $rs->fetch(); 
     89if ($rowdata) { 
    9190if(ereg("iPhone",$useragent)){ 
    9291        print "<ul id=\"home\" title=\"録画ライブラリ表示\" selected=\"true\">"; 
     
    105104"; 
    106105} 
    107 for ($row = 0; $row < $maxrows; $row++) { 
    108         $rowdata = pg_fetch_row($rs, $row); 
     106        do { 
    109107$title = $rowdata[1]; 
    110108$counts = $rowdata[2]; 
     
    125123"; 
    126124} 
    127 }//for 
     125        } while ($rowdata = $rs->fetch()); 
    128126 
    129127if(ereg("iPhone",$useragent)){ 
     
    160158"; 
    161159$rs = m_query($con, $query, "DBクエリに失敗しました"); 
    162 $rowdata = pg_fetch_row($rs, $row); 
     160$rowdata = $rs->fetch(); 
    163161//print" $fName./$rowdata[1]/$rowdata[2]/$rowdata[3]<BR>\n"; 
    164162$title = $rowdata[1]; 
  • trunk/install/php/showlibc.php

    r83 r94  
    6868SELECT foltia_program.title   
    6969FROM  foltia_program    
    70 WHERE foltia_program.tid = $tid   
    71 "; 
    72 $rs = m_query($con, $query, "DBクエリに失敗しました"); 
    73 $maxrows = pg_num_rows($rs); 
    74 if ($maxrows == 0 ){ 
    75  $syobocaldb = `curl "http://cal.syoboi.jp/db?Command=TitleLookup&TID=$tid" | head -2 `; 
     70WHERE foltia_program.tid = ?  
     71"; 
     72//$rs = m_query($con, $query, "DBクエリに失敗しました"); 
     73$rs = sql_query($con, $query, "DBクエリに失敗しました",array($tid)); 
     74$rowdata = $rs->fetch(); 
     75if (! $rowdata) { 
     76$syobocaldb = `curl "http://cal.syoboi.jp/db?Command=TitleLookup&TID=$tid" | head -2 `; 
    7677$syobocaldb = mb_convert_encoding($syobocaldb, "EUC-JP", "UTF-8"); 
    7778        $syobocaldb = preg_match("/<Title>.*<\/Title>/", $syobocaldb,$title); 
     
    8081        $title =  htmlspecialchars($title) ; 
    8182}else{ 
    82 $rowdata = pg_fetch_row($rs, 0); 
    8383$title = $rowdata[0]; 
    8484$title =  htmlspecialchars($title) ; 
     
    143143LEFT JOIN foltia_program   
    144144ON foltia_mp4files.tid = foltia_program.tid  
    145 WHERE foltia_mp4files.tid = $tid   
     145WHERE foltia_mp4files.tid = ?   
    146146ORDER BY \"startdatetime\" ASC 
    147147"; 
    148148 
    149149$rs = ""; 
    150 $rs = m_query($con, $query, "DBクエリに失敗しました"); 
    151 $maxrows = pg_num_rows($rs); 
    152 if ($maxrows > 0 ){ 
     150//$rs = m_query($con, $query, "DBクエリに失敗しました"); 
     151$rs = sql_query($con, $query, "DBクエリに失敗しました",array($tid)); 
     152$rowdata = $rs->fetch(); 
     153if ($rowdata) { 
    153154if(ereg("iPhone",$useragent)){ 
    154155        print "<ul id=\"home\" title=\"$title\" selected=\"true\">"; 
     
    159160"; 
    160161} 
    161 for ($row = 0; $row < $maxrows; $row++) { 
    162         $rowdata = pg_fetch_row($rs, $row); 
    163  
     162        do { 
    164163$title = $rowdata[1]; 
    165164 
     
    195194} 
    196195//Starlight Breaker向け拡張 
    197 //$debug_pg_num_rows = pg_num_rows ($rs ); 
     196//$debug_pg_num_rows = $rs ->rowCount(); 
    198197$caplink = ""; 
    199198 
    200 if (($sbpluginexist == 1) && (pg_num_rows ($rs ) > 0))
     199               if ($sbpluginexist == 1)
    201200 //$capimgpath = htmlspecialchars(preg_replace("/.m2p/", "", $rowdata[5])); 
    202201 $capimgpath = htmlspecialchars(preg_replace("/.m2./", "", $rowdata[5])); 
     
    244243}//endif iPhone 
    245244 
    246 }//for 
     245        } while ($rowdata = $rs->fetch()); 
    247246}else{ 
    248247print "録画ファイルがありません<br>\n"; 
  • trunk/install/php/showplaylist.php

    r83 r94  
    115115FROM foltia_subtitle , foltia_program    
    116116WHERE foltia_program.tid = foltia_subtitle.tid   
    117  AND foltia_subtitle.tid = $filesplit[0]  
    118 "; 
    119 $rs = m_query($con, $query, "DBクエリに失敗しました"); 
    120 $rowdata = pg_fetch_row($rs, $row); 
     117 AND foltia_subtitle.tid = ?  
     118"; 
     119//$rs = m_query($con, $query, "DBクエリに失敗しました"); 
     120$rs = sql_query($con, $query, "DBクエリに失敗しました",array($filesplit[0])); 
     121                                $rall = $rs->fetchAll(); 
     122                                $rowdata = $rall[$row]; 
    121123//print" $fName./$rowdata[1]//$rowdata[2]<BR>\n"; 
    122124$title = $rowdata[1]; 
     
    130132FROM foltia_subtitle , foltia_program    
    131133WHERE foltia_program.tid = foltia_subtitle.tid   
    132  AND foltia_subtitle.tid = $filesplit[0]  
    133  AND foltia_subtitle.countno = $filesplit[1]  
    134 "; 
    135 $rs = m_query($con, $query, "DBクエリに失敗しました"); 
    136 $rowdata = pg_fetch_row($rs, $row); 
     134 AND foltia_subtitle.tid = ?  
     135 AND foltia_subtitle.countno = ?  
     136"; 
     137//$rs = m_query($con, $query, "DBクエリに失敗しました"); 
     138$rs = sql_query($con, $query, "DBクエリに失敗しました",array($filesplit[0],$filesplit[1])); 
     139                                $rall = $rs->fetchAll(); 
     140                                $rowdata = $rall[$row]; 
    137141//print" $fName./$rowdata[1]/$rowdata[2]/$rowdata[3]<BR>\n"; 
    138142$title = $rowdata[1]; 
     
    197201} 
    198202 
    199 $rs = m_query($con, $query, "DBクエリに失敗しました"); 
    200 $maxrows = pg_num_rows($rs); 
    201  
    202 if ($maxrows > 0){ 
    203 for ($row = 0; $row < $maxrows; $row++) {  
    204 $rowdata = pg_fetch_row($rs, $row); 
    205  
     203//$rs = m_query($con, $query, "DBクエリに失敗しました"); 
     204$rs = sql_query($con, $query, "DBクエリに失敗しました"); 
     205$rowdata = $rs->fetch(); 
     206if ($rowdata) { 
     207        do { 
    206208$tid = htmlspecialchars($rowdata[0]); 
    207209$title = htmlspecialchars($rowdata[1]); 
     
    235237print "</tr>\n 
    236238"; 
    237 }//for 
     239        } while ($rowdata = $rs->fetch()); 
    238240}else{ 
    239241print " 
     
    262264"; 
    263265 
    264 $rs = m_query($con, $query, "DBクエリに失敗しました"); 
    265 $maxrows = pg_num_rows($rs); 
    266  
    267  
    268 if ($maxrows > 0){ 
     266//$rs = m_query($con, $query, "DBクエリに失敗しました"); 
     267$rs = sql_query($con, $query, "DBクエリに失敗しました"); 
     268        $rowdata = $rs->fetch(); 
     269        if ($rowdata) { 
    269270print "<hr> 
    270271<p align=\"left\">未読タイトルを表示します。<br> 
     
    279280"; 
    280281 
    281 for ($row = 0; $row < $maxrows; $row++) {  
    282 $rowdata = pg_fetch_row($rs, $row); 
    283  
     282                do { 
    284283$tid = htmlspecialchars($rowdata[0]); 
    285284$title = htmlspecialchars($rowdata[1]); 
    286285 
    287  
    288286print "<tr><td>$tid</td><td>$title</td></tr>\n"; 
    289287 
    290 }//for 
     288                } while ($rowdata = $rs->fetch()); 
    291289print "</tbody></table>\n"; 
    292290}//if maxrows 
  • trunk/install/php/titlelist.php

    r70 r94  
    5151ORDER BY foltia_program.tid  DESC 
    5252        "; 
    53       $rs = m_query($con, $query, "DBクエリに失敗しました"); 
    54        $maxrows = pg_num_rows($rs); 
    55                          
    56                if ($maxrows == 0) { 
     53//    $rs = m_query($con, $query, "DBクエリに失敗しました"); 
     54$rs = sql_query($con, $query, "DBクエリに失敗しました"); 
     55$rowdata = $rs->fetch(); 
     56if (! $rowdata) { 
    5757                die_exit("番組データがありません<BR>"); 
    58                          
    5958                } 
    60  
    6159?> 
    6260 
     
    7270<? 
    7371                /* フィールド数 */ 
    74                $maxcols = pg_num_fields($rs); 
     72$maxcols = $rs->columnCount(); 
    7573                ?> 
    7674  <table BORDER="0" CELLPADDING="0" CELLSPACING="2" WIDTH="100%"> 
     
    8684                <?php 
    8785                        /* テーブルのデータを出力 */ 
    88                         for ($row = 0; $row < $maxrows; $row++) { /* 行に対応 */ 
     86    do { 
    8987                                echo("<tr>\n"); 
    90                                 /* pg_fetch_row で一行取り出す */ 
    91                                 $rowdata = pg_fetch_row($rs, $row); 
     88 
    9289                                //TID 
    9390                                        echo("<td><a href=\"reserveprogram.php?tid=" . 
     
    10097                                        print "<td><A HREF = \"showlibc.php?tid=".htmlspecialchars($rowdata[0])."\">mp4</A></td>\n"; 
    10198                                echo("</tr>\n"); 
    102                         } 
     99    } while ($rowdata = $rs->fetch()); 
    103100                ?> 
    104101        </tbody> 
  • trunk/install/php/view_syabas.php

    r86 r94  
    5656FROM foltia_subtitle , foltia_program ,foltia_station   
    5757WHERE foltia_program.tid = foltia_subtitle.tid AND foltia_station.stationid = foltia_subtitle.stationid  
    58  AND foltia_subtitle.pid = '$pid'   
    59   
    60         "; 
    61         $rs = m_query($con, $query, "DBクエリに失敗しました"); 
    62  
    63 $rows = pg_num_rows($rs); 
    64 if ($rows == 0){ 
     58 AND foltia_subtitle.pid = ? "; 
     59//      $rs = m_query($con, $query, "DBクエリに失敗しました"); 
     60$rs = sql_query($con, $query, "DBクエリに失敗しました",array($pid)); 
     61$rowdata = $rs->fetch(); 
     62if (! $rowdata) { 
    6563        print ""; 
    6664        exit; 
    6765}else{ 
    68 $rowdata = pg_fetch_row($rs, 0); 
    69  
    7066$title = $rowdata[2]; 
    7167$episode = $rowdata[3]; 
  • trunk/install/php/viewepg.php

    r91 r94  
    9191$maxdisplay = 8; 
    9292 
    93         $query = "SELECT stationid, stationname, stationrecch, ontvcode FROM foltia_station WHERE \"ontvcode\" ~~ '%ontvjapan%'  
    94         "; 
    95         $rs = m_query($con, $query, "DBクエリに失敗しました"); 
    96         $maxrows = pg_num_rows($rs); 
    97  
     93$query = "SELECT count(*) FROM foltia_station WHERE \"ontvcode\" LIKE '%ontvjapan%'"; 
     94//$rs = m_query($con, $query, "DBクエリに失敗しました"); 
     95$rs = sql_query($con, $query, "DBクエリに失敗しました"); 
     96$maxrows = $rs->fetchColumn(0); 
    9897if ($maxrows > $maxdisplay){ 
    9998        $pages = ceil($maxrows / $maxdisplay) ; 
     
    138137$query = "SELECT stationid, stationname, stationrecch, ontvcode  
    139138FROM foltia_station  
    140 WHERE \"ontvcode\" ~~ '%ontvjapan%'   
     139WHERE \"ontvcode\" LIKE '%ontvjapan%'   
    141140ORDER BY stationid ASC , stationrecch  
    142 OFFSET $offset LIMIT $maxdisplay  
     141LIMIT ? OFFSET ? 
    143142"; 
    144 $slistrs = m_query($con, $query, "DBクエリに失敗しました"); 
    145 $stations =  pg_num_rows($slistrs); 
    146 for ($i=0 ; $i < $stations ; $i++){ 
    147         $rowdata = pg_fetch_row($slistrs, $i); 
    148         $stationhash[$i] = $rowdata[3] ; 
     143 
     144//$slistrs = m_query($con, $query, "DBクエリに失敗しました"); 
     145$slistrs = sql_query($con, $query, "DBクエリに失敗しました",array($maxdisplay,$offset)); 
     146while ($rowdata = $slistrs->fetch()) { 
     147        $stationhash[] = $rowdata[3]; 
     148        $snames[] = $rowdata[1]; // headder 
    149149} 
    150150 
     
    158158        SELECT ontvcode  
    159159        FROM foltia_station  
    160         WHERE \"ontvcode\" ~~ '%ontvjapan%'   
     160        WHERE \"ontvcode\" LIKE '%ontvjapan%'   
    161161        ORDER BY stationid ASC , stationrecch  
    162         OFFSET $offset LIMIT $maxdisplay 
     162        LIMIT ? OFFSET ? 
    163163        ) 
    164 AND startdatetime  >= $start  
    165 AND startdatetime  < $epgend  
     164AND startdatetime  >= ?  
     165AND startdatetime  < ?  
    166166ORDER BY foltia_epg.startdatetime  ASC  "; 
    167167 
    168 $rs = m_query($con, $query, "DBクエリに失敗しました"); 
     168//$rs = m_query($con, $query, "DBクエリに失敗しました"); 
     169$rs = sql_query($con, $query, "DBクエリに失敗しました",array($maxdisplay,$offset,$start,$epgend)); 
    169170 
    170171//print "$query<br>\n"; 
    171172 
    172 $colmnums =  pg_num_rows($rs); 
    173 if ($colmnums == 0)
     173$rowdata = $rs->fetch(); 
     174if (! $rowdata)
    174175//番組データがない 
    175176$colmnums = 2; 
    176177}else{ 
    177         for ($i=0 ; $i < $colmnums ; $i++){ 
    178                 $rowdata = pg_fetch_row($rs, $i); 
    179                 $timetablehash["$rowdata[0]"] = ($i + 1); 
     178        $colmnums = 0; 
     179        do { 
     180                $colmnums++; 
     181                $timetablehash[$rowdata[0]] = $colmnums; 
    180182//              print "$rowdata[0]:$i+1 <br>\n"; 
    181         } 
     183        } while ($rowdata = $rs->fetch()); 
    182184} 
    183185//print "colmnums $colmnums <br>\n"; 
    184186 
    185187//・局ごとに縦に配列入れていく 
    186 for ($j=0 ; $j < $stations ; $j++){ 
    187         $rowdata = pg_fetch_row($slistrs, $j); 
    188         $stationname = $rowdata[3]; 
    189  
     188foreach ($stationhash as $stationname) { 
    190189$epgstart = $start ; 
    191190$epgend = calcendtime($start , (8*60)); 
     
    193192SELECT startdatetime , enddatetime , lengthmin , epgtitle , epgdesc , epgcategory  ,ontvchannel  ,epgid ,       epgcategory  
    194193FROM foltia_epg  
    195 WHERE foltia_epg.ontvchannel = '$stationname' AND  
    196 enddatetime  > $epgstart  AND  
    197 startdatetime  < $epgend   
     194WHERE foltia_epg.ontvchannel = ? AND  
     195enddatetime  > ?  AND  
     196startdatetime  < ?   
    198197ORDER BY foltia_epg.startdatetime  ASC 
    199198        "; 
    200         $statiodh = m_query($con, $query, "DBクエリに失敗しました"); 
    201         $maxrowsstation = pg_num_rows($statiodh); 
    202  
    203 //print "maxrowsstation $maxrowsstation  stationname $stationname<br>\n"; 
    204  
    205 if ($maxrowsstation == 0) { 
     199 
     200//      $statiodh = m_query($con, $query, "DBクエリに失敗しました"); 
     201        $statiodh = sql_query($con, $query, "DBクエリに失敗しました",array($stationname,$epgstart,$epgend)); 
     202        $stationrowdata = $statiodh->fetch(); 
     203        if (! $stationrowdata) { 
    206204                //print("番組データがありません<BR>"); 
    207205                $item[0]["$stationname"] =  ">番組データがありません"; 
    208206}else{ 
    209  
    210 for ($srow = 0; $srow < $maxrowsstation ; $srow++) {  
    211           
    212 $stationrowdata = pg_fetch_row($statiodh, $srow); 
    213  
     207                do { 
    214208$printstarttime = substr($stationrowdata[0],8,2) . ":" .  substr($stationrowdata[0],10,2); 
    215209$tdclass = "t".substr($stationrowdata[0],8,2) .  substr($stationrowdata[0],10,2); 
     
    235229}//if 
    236230 
    237 }//for 
     231                } while ($stationrowdata = $statiodh->fetch()); 
    238232}//if 
    239233 
     
    291285 
    292286//ヘッダ 
    293 for ($i=0;$i<$stations;$i++){ 
    294         $rowdata = pg_fetch_row($slistrs, $i); 
    295         print "<th>".htmlspecialchars($rowdata[1])."</th>" ; 
     287foreach ($snames as $s) { 
     288        print "<th>".htmlspecialchars($s)."</th>" ; 
    296289} 
    297290//本体 
    298291for ($l = 0 ;$l <  $colmnums; $l++){ 
    299292        print "<tr>"; 
    300         for ($m = 0 ; $m < $stations ; $m++ ){ 
    301                 $stationname = $stationhash[$m]; 
     293        foreach ($stationhash as $stationname) { 
    302294                print_r($item[$l]["$stationname"]); 
    303295        } 
track feed