Index: trunk/install/php/reservecomp.php =================================================================== --- trunk/install/php/reservecomp.php (リビジョン 83) +++ trunk/install/php/reservecomp.php (リビジョン 94) @@ -67,12 +67,11 @@ //タイトル取得 - $query = "select title from foltia_program where tid='$tid'"; - $rs = m_query($con, $query, "DBクエリに失敗しました"); - $maxrows = pg_num_rows($rs); - - if ($maxrows == 0) { + $query = "select title from foltia_program where tid = ? "; +// $rs = m_query($con, $query, "DBクエリに失敗しました"); + $rs = sql_query($con, $query, "DBクエリに失敗しました",array($tid)); +$rowdata = $rs->fetch(); +if (! $rowdata) { $title = "(未登録)"; }else{ - $rowdata = pg_fetch_row($rs, 0); $title = htmlspecialchars($rowdata[0]); } @@ -130,11 +129,10 @@ } $rs = m_query($con, $query, "DBクエリに失敗しました"); - $maxrows = pg_num_rows($rs); - - if ($maxrows == 0) { +$rowdata = $rs->fetch(); +if (! $rowdata) { echo("放映予定はいまのところありません
"); } else{ - $maxcols = pg_num_fields($rs); + $maxcols = $rs->columnCount(); ?> @@ -155,14 +153,11 @@ \n"); - /* pg_fetch_row で一行取り出す */ - $rowdata = pg_fetch_row($rs, $row); - for ($col = 0; $col < $maxcols; $col++) { /* 列に対応 */ echo("\n"); } echo("\n"); - } + } while ($rowdata = $rs->fetch()); }//end if ?> @@ -177,38 +172,31 @@ //既存が予約あって、新着が全局予約だったら if ($station ==0){ - $query = " -SELECT - * -FROM foltia_tvrecord -WHERE tid = '$tid' -"; - $rs = m_query($con, $query, "DBクエリに失敗しました"); - $maxrows = pg_num_rows($rs); - if ($maxrows > 0){ //既存局を消す $query = "DELETE FROM foltia_tvrecord -WHERE tid = '$tid' -"; - $rs = m_query($con, $query, "DBクエリに失敗しました"); - } +WHERE tid = ? +"; +// $rs = m_query($con, $query, "DBクエリに失敗しました"); + $rs = sql_query($con, $query, "DBクエリに失敗しました",array($tid)); }//endif $query = " SELECT - * +count(*) FROM foltia_tvrecord -WHERE tid = '$tid' AND stationid = '$station' -"; - $rs = m_query($con, $query, "DBクエリに失敗しました"); - $maxrows = pg_num_rows($rs); - +WHERE tid = ? AND stationid = ? +"; +// $rs = m_query($con, $query, "DBクエリに失敗しました"); + $rs = sql_query($con, $query, "DBクエリに失敗しました",array($tid,$station)); + $maxrows = $rs->fetchColumn(0); if ($maxrows == 0) { //新規追加 - $query = "INSERT INTO foltia_tvrecord values ('$tid','$station','$bitrate','$usedigital')"; - $rs = m_query($con, $query, "DB書き込みに失敗しました"); + $query = "INSERT INTO foltia_tvrecord values (?,?,?,?)"; +// $rs = m_query($con, $query, "DB書き込みに失敗しました"); + $rs = sql_query($con, $query, "DB書き込みに失敗しました",array($tid,$station,$bitrate,$usedigital)); }else{//修正 (ビットレート) $query = "UPDATE foltia_tvrecord SET - bitrate = '$bitrate' , digital = '$usedigital' WHERE tid = '$tid' AND stationid = '$station' "; - $rs = m_query($con, $query, "DB書き込みに失敗しました"); + bitrate = ? , digital = ? WHERE tid = ? AND stationid = ? "; +// $rs = m_query($con, $query, "DB書き込みに失敗しました"); + $rs = sql_query($con, $query, "DB書き込みに失敗しました",array( $bitrate, $usedigital , $tid , $station )); } Index: trunk/install/php/folcast.php =================================================================== --- trunk/install/php/folcast.php (リビジョン 70) +++ trunk/install/php/folcast.php (リビジョン 94) @@ -51,5 +51,5 @@ $query = " SELECT foltia_program.tid,foltia_program.title, -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 +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\" LIKE 'M%%' AND foltia_program.tid = foltia_subtitle.tid AND foltia_program.tid = $tid ORDER BY \"enddatetime\" DESC offset 0 limit $max @@ -59,8 +59,9 @@ SELECT foltia_program.tid,foltia_program.title FROM foltia_program -WHERE foltia_program.tid = $tid +WHERE foltia_program.tid = ? "; - $titlers = m_query($con, $query, "DBクエリに失敗しました"); - $rowdata = pg_fetch_row($titlers, 0); +// $titlers = m_query($con, $query, "DBクエリに失敗しました"); + $titlers = sql_query($con, $query, "DBクエリに失敗しました",array($tid)); + $rowdata = $titlers->fetch(); $rsstitle = $rowdata[1]; }else{ @@ -68,6 +69,6 @@ $query = " SELECT foltia_program.tid,foltia_program.title, -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 -offset 0 limit $max +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\" LIKE 'M%%' AND foltia_program.tid = foltia_subtitle.tid ORDER BY \"enddatetime\" DESC +offset 0 limit ? "; $rsstitle = "新規録画"; @@ -96,14 +97,12 @@ print $header; - $rs = m_query($con, $query, "DBクエリに失敗しました"); - $maxrows = pg_num_rows($rs); +// $rs = m_query($con, $query, "DBクエリに失敗しました"); + $rs = sql_query($con, $query, "DBクエリに失敗しました",array($max)); +$rowdata = $rs->fetch(); -if ($maxrows == 0) { +if (! $rowdata) { //die_exit("No items"); }else{ - -for ($row = 0; $row < $maxrows; $row++) { - $rowdata = pg_fetch_row($rs, $row); - + do { //$title = mb_convert_encoding($rowdata[1],"UTF-8", "EUC-JP"); $tid = $rowdata[0]; @@ -163,5 +162,5 @@ print $item ; -}//for + } while ($rowdata = $rs->fetch()); //do }//if Index: trunk/install/php/m.php =================================================================== --- trunk/install/php/m.php (リビジョン 83) +++ trunk/install/php/m.php (リビジョン 94) @@ -97,12 +97,9 @@ SELECT stationname FROM foltia_station -WHERE stationid = $recstid"; - $stationvalid = m_query($con, $query, "DBクエリに失敗しました"); - $stationcount = pg_num_rows($stationvalid); - - if ($stationcount == 1){ - $recstationname = pg_fetch_row($stationvalid, 0); - //valid - }else{ +WHERE stationid = ? "; +// $stationvalid = m_query($con, $query, "DBクエリに失敗しました"); + $stationvalid = sql_query($con, $query, "DBクエリに失敗しました",array($recstid)); + $recstationname = $stationvalid->fetch(); + if (! $recstationname) { $errflag = 3; $errmsg = "放送局設定が異常です。"; @@ -128,21 +125,25 @@ //min pidを探す $query = "SELECT min(pid) FROM foltia_subtitle "; - $rs = m_query($con, $query, "DBクエリに失敗しました"); - $maxrows = pg_num_rows($rs); - if ($maxrows == 0){ - $insertpid = -1 ; +// $rs = m_query($con, $query, "DBクエリに失敗しました"); + $rs = sql_query($con, $query, "DBクエリに失敗しました"); + $rowdata = $rs->fetch(); + if (! $rowdata) { + $insertpid = -1 ; }else{ - $rowdata = pg_fetch_row($rs, 0); - $insertpid = $rowdata[0]; - $insertpid-- ; + if ($rowdata[0] > 0) { + $insertpid = -1 ; + }else{ + $insertpid = $rowdata[0]; + $insertpid-- ; + } } // next 話数を探す $query = "SELECT max(countno) FROM foltia_subtitle WHERE tid = 0"; - $rs = m_query($con, $query, "DBクエリに失敗しました"); - $maxrows = pg_num_rows($rs); - if ($maxrows == 0){ +// $rs = m_query($con, $query, "DBクエリに失敗しました"); + $rs = sql_query($con, $query, "DBクエリに失敗しました"); + $rowdata = $rs->fetch(); + if (! $rowdata) { $nextcno = 1 ; }else{ - $rowdata = pg_fetch_row($rs, 0); $nextcno = $rowdata[0]; $nextcno++ ; @@ -159,8 +160,9 @@ insert into foltia_subtitle (pid ,tid ,stationid , countno ,subtitle , startdatetime ,enddatetime ,startoffset , lengthmin , epgaddedby ) - values ( '$insertpid','0','$recstid', - '$nextcno','$pname','$startdatetime','$enddatetime','0' ,'$lengthmin', '$memberid')"; + values ( ?,'0',?,?,?,?,?,'0',?,?)"; - $rs = m_query($con, $query, "DBクエリに失敗しました"); +// $rs = m_query($con, $query, "DBクエリに失敗しました"); +//print "【DEBUG】$insertpid,$recstid,$nextcno,$pname,$startdatetime,$enddatetime ,$lengthmin,$memberid
\n"; + $rs = sql_query($con, $query, "DBクエリに失敗しました",array($insertpid,$recstid,$nextcno,$pname,$startdatetime,$enddatetime ,$lengthmin,$memberid)); //addatq.pl @@ -168,6 +170,21 @@ //引数 TID チャンネルID //echo("$toolpath/perl/addatq.pl $tid $station"); - - $oserr = system("$toolpath/perl/addatq.pl 0 0"); + exec("$toolpath/perl/addatq.pl 0 0"); + $oserr = system("$toolpath/perl/addatq.pl 0 0"); + //--------------------------------------------------- + if ($oserr){ + print "[DEBUG]$oserr 「$toolpath/perl/addatq.pl 0 0」
\n"; + }else{ + print "[DEBUG]exec addatq.pl false 「$toolpath/perl/addatq.pl 0 0」
\n"; + + $oserr = system("$toolpath/perl/perltestscript.pl"); + if ($oserr){ + print "[DEBUG]exec perltestscript.pl $oserr
\n"; + }else{ + print "[DEBUG]exec perltestscript.pl false
\n"; + } + + } + //----------------------------------------------------- }else{ print "EPG予約を行う権限がありません。"; @@ -200,5 +217,5 @@ }// 初回表示かデータ処理か ?> - +

放送日: @@ -215,5 +232,5 @@ 0 @@ -221,35 +238,33 @@ SELECT DISTINCT stationid,stationname,stationrecch ,digitalch FROM foltia_station -WHERE digitalch > 0 -ORDER BY \"stationid\" ASC"; - - $stations = m_query($con, $query, "DBクエリに失敗しました"); - $stationcount = pg_num_rows($stations); - -if ($stationcount > 0 ){ - for ($row = 0; $row < $stationcount ; $row++) { - $rowdata = pg_fetch_row($stations, $row); +WHERE digitalch > 0 +ORDER BY x ASC"; + +$stations = sql_query($con, $query, "DBクエリに失敗しました"); +$rowdata = $stations->fetch(); + +if ($rowdata) { + do { if ($recstid == $rowdata[0]){ - print " $rowdata[1] ($rowdata[2]ch) \n"; + print " $rowdata[1] ($rowdata[2]ch / $rowdata[3]ch) \n"; }else{ - print " $rowdata[1] ($rowdata[2]ch) \n"; + print " $rowdata[1] ($rowdata[2]ch / $rowdata[3]ch) \n"; } - } + } while ($rowdata = $stations->fetch()); }else{ print "放送局データベースが正しくセットアップされていません。録画可能局がありません"; } - +//外部入力チャンネル $query = " -SELECT stationid,stationname,stationrecch +SELECT stationid as x ,stationname,stationrecch FROM foltia_station WHERE stationrecch > -2 AND stationrecch < 1 -ORDER BY \"stationid\" ASC"; - - $stations = m_query($con, $query, "DBクエリに失敗しました"); - $stationcount = pg_num_rows($stations); - -if ($stationcount > 0 ){ - for ($row = 0; $row < $stationcount ; $row++) { - $rowdata = pg_fetch_row($stations, $row); +ORDER BY x ASC"; + +// $stations = m_query($con, $query, "DBクエリに失敗しました"); + $stations = sql_query($con, $query, "DBクエリに失敗しました"); +$rowdata = $stations->fetch(); +if ($rowdata) { + do { if ($rowdata[0] != 0){ if ($recstid == $rowdata[0]){ @@ -260,5 +275,5 @@ } - } + } while ($rowdata = $stations->fetch()); } /* Index: trunk/install/php/foltia_config2.php.template =================================================================== --- trunk/install/php/foltia_config2.php.template (リビジョン 83) +++ trunk/install/php/foltia_config2.php.template (リビジョン 94) @@ -27,8 +27,6 @@ // データベース接続設定 - define("DATABASE_NAME", "foltia"); - define("DBHOST", "localhost"); - define("USER_NAME" , "foltia" ); - define("USER_PASSWORD", "passwd" ); +// define("DSN", "pgsql:host=localhost dbname=foltia user=foltia password= "); +define("DSN", "sqlite:/home/foltia/foltia.sqlite"); // $mylocalip = "192.168.0.177" ; //動いている機械のIPアドレス Index: trunk/install/php/delreserve.php =================================================================== --- trunk/install/php/delreserve.php (リビジョン 70) +++ trunk/install/php/delreserve.php (リビジョン 94) @@ -44,10 +44,9 @@ "); } -$sid = getgetnumform(sid); + $sid = getgetnumform("sid"); if ($sid == "") { die_exit("局がありません
"); @@ -70,14 +69,13 @@ foltia_tvrecord.stationid FROM foltia_tvrecord , foltia_program , foltia_station -WHERE foltia_tvrecord.tid = foltia_program.tid AND foltia_tvrecord.stationid = foltia_station .stationid AND foltia_tvrecord.tid = $tid AND foltia_tvrecord.stationid = $sid "; - - $rs = m_query($con, $query, "DBクエリに失敗しました"); - $maxrows = pg_num_rows($rs); - - if ($maxrows == 0) { +WHERE foltia_tvrecord.tid = foltia_program.tid AND foltia_tvrecord.stationid = foltia_station .stationid AND foltia_tvrecord.tid = ? AND foltia_tvrecord.stationid = ? "; + +// $rs = m_query($con, $query, "DBクエリに失敗しました"); + $rs = sql_query($con, $query, "DBクエリに失敗しました",array($tid,$sid)); +$rowdata = $rs->fetch(); + +if (! $rowdata ) { die_exit("登録番組がありません
"); } - $rowdata = pg_fetch_row($rs, 0); - $tid = htmlspecialchars($rowdata[0]); $stationname = htmlspecialchars($rowdata[1]); @@ -107,6 +105,8 @@ DELETE FROM foltia_tvrecord -WHERE foltia_tvrecord.tid = $tid AND foltia_tvrecord.stationid = $sid "; - $rs = m_query($con, $query, "DBクエリに失敗しました"); +WHERE foltia_tvrecord.tid = ? AND foltia_tvrecord.stationid = ? "; +$rs->closeCursor(); +// $rs = m_query($con, $query, "DBクエリに失敗しました"); + $rs = sql_query($con, $query, "DBクエリに失敗しました",array($tid,$sid)); } @@ -164,15 +164,14 @@ FROM foltia_subtitle , foltia_program ,foltia_station WHERE foltia_program.tid = foltia_subtitle.tid AND foltia_station.stationid = foltia_subtitle.stationid - AND foltia_subtitle.startdatetime >= '$now' AND foltia_program.tid ='$tid' + AND foltia_subtitle.startdatetime >= ? AND foltia_program.tid = ? ORDER BY foltia_subtitle.startdatetime ASC "; - $rs = m_query($con, $query, "DBクエリに失敗しました"); - $maxrows = pg_num_rows($rs); - - if ($maxrows == 0) { +// $rs = m_query($con, $query, "DBクエリに失敗しました"); + $rs = sql_query($con, $query, "DBクエリに失敗しました",array($now,$tid)); +$rowdata = $rs->fetch(); +if (! $rowdata) { echo("放映予定はありません
"); - } - else{ - $maxcols = pg_num_fields($rs); +}else{ + $maxcols = $rs->columnCount(); ?>

".htmlspecialchars($rowdata[$col])."
@@ -192,14 +191,11 @@ \n"); - /* pg_fetch_row で一行取り出す */ - $rowdata = pg_fetch_row($rs, $row); - for ($col = 0; $col < $maxcols; $col++) { /* 列に対応 */ echo("\n"); } echo("\n"); - } + } while ($row = $rs->fetch()); }//end if ?> Index: trunk/install/php/deletemovie.php =================================================================== --- trunk/install/php/deletemovie.php (リビジョン 76) +++ trunk/install/php/deletemovie.php (リビジョン 94) @@ -88,8 +88,10 @@ FROM foltia_subtitle , foltia_program WHERE foltia_program.tid = foltia_subtitle.tid - AND foltia_subtitle.tid = $filesplit[0] + AND foltia_subtitle.tid = ? "; -$rs = m_query($con, $query, "DBクエリに失敗しました"); -$rowdata = pg_fetch_row($rs, $row); +//$rs = m_query($con, $query, "DBクエリに失敗しました"); +$rs = sql_query($con, $query, "DBクエリに失敗しました",array($filesplit[0])); + $rall = $rs->fetchAll(); + $rowdata = $rall[$row]; //print" $fName./$rowdata[1]//$rowdata[2]
\n"; $title = $rowdata[1]; @@ -103,9 +105,11 @@ FROM foltia_subtitle , foltia_program WHERE foltia_program.tid = foltia_subtitle.tid - AND foltia_subtitle.tid = $filesplit[0] - AND foltia_subtitle.countno = $filesplit[1] + AND foltia_subtitle.tid = ? + AND foltia_subtitle.countno = ? "; -$rs = m_query($con, $query, "DBクエリに失敗しました"); -$rowdata = pg_fetch_row($rs, $row); +//$rs = m_query($con, $query, "DBクエリに失敗しました"); +$rs = sql_query($con, $query, "DBクエリに失敗しました",array($filesplit[0] ,$filesplit[1])); + $rall = $rs->fetchAll(); + $rowdata = $rall[$row]; //print" $fName./$rowdata[1]/$rowdata[2]/$rowdata[3]
\n"; $title = $rowdata[1]; @@ -119,7 +123,4 @@ $count = htmlspecialchars($count); $subtitle = htmlspecialchars($subtitle); - -//-- - print " @@ -138,7 +139,8 @@ $query = " DELETE FROM foltia_m2pfiles -WHERE m2pfilename = '$fName' +WHERE m2pfilename = ? "; -$rs = m_query($con, $query, "DBクエリに失敗しました"); +//$rs = m_query($con, $query, "DBクエリに失敗しました"); +$rs = sql_query($con, $query, "DBクエリに失敗しました",array($fName)); //削除処理 Index: trunk/install/php/showplaylist.php =================================================================== --- trunk/install/php/showplaylist.php (リビジョン 83) +++ trunk/install/php/showplaylist.php (リビジョン 94) @@ -115,8 +115,10 @@ FROM foltia_subtitle , foltia_program WHERE foltia_program.tid = foltia_subtitle.tid - AND foltia_subtitle.tid = $filesplit[0] -"; -$rs = m_query($con, $query, "DBクエリに失敗しました"); -$rowdata = pg_fetch_row($rs, $row); + AND foltia_subtitle.tid = ? +"; +//$rs = m_query($con, $query, "DBクエリに失敗しました"); +$rs = sql_query($con, $query, "DBクエリに失敗しました",array($filesplit[0])); + $rall = $rs->fetchAll(); + $rowdata = $rall[$row]; //print" $fName./$rowdata[1]//$rowdata[2]
\n"; $title = $rowdata[1]; @@ -130,9 +132,11 @@ FROM foltia_subtitle , foltia_program WHERE foltia_program.tid = foltia_subtitle.tid - AND foltia_subtitle.tid = $filesplit[0] - AND foltia_subtitle.countno = $filesplit[1] -"; -$rs = m_query($con, $query, "DBクエリに失敗しました"); -$rowdata = pg_fetch_row($rs, $row); + AND foltia_subtitle.tid = ? + AND foltia_subtitle.countno = ? +"; +//$rs = m_query($con, $query, "DBクエリに失敗しました"); +$rs = sql_query($con, $query, "DBクエリに失敗しました",array($filesplit[0],$filesplit[1])); + $rall = $rs->fetchAll(); + $rowdata = $rall[$row]; //print" $fName./$rowdata[1]/$rowdata[2]/$rowdata[3]
\n"; $title = $rowdata[1]; @@ -197,11 +201,9 @@ } -$rs = m_query($con, $query, "DBクエリに失敗しました"); -$maxrows = pg_num_rows($rs); - -if ($maxrows > 0){ -for ($row = 0; $row < $maxrows; $row++) { -$rowdata = pg_fetch_row($rs, $row); - +//$rs = m_query($con, $query, "DBクエリに失敗しました"); +$rs = sql_query($con, $query, "DBクエリに失敗しました"); +$rowdata = $rs->fetch(); +if ($rowdata) { + do { $tid = htmlspecialchars($rowdata[0]); $title = htmlspecialchars($rowdata[1]); @@ -235,5 +237,5 @@ print "\n "; -}//for + } while ($rowdata = $rs->fetch()); }else{ print " @@ -262,9 +264,8 @@ "; -$rs = m_query($con, $query, "DBクエリに失敗しました"); -$maxrows = pg_num_rows($rs); - - -if ($maxrows > 0){ +//$rs = m_query($con, $query, "DBクエリに失敗しました"); +$rs = sql_query($con, $query, "DBクエリに失敗しました"); + $rowdata = $rs->fetch(); + if ($rowdata) { print "

未読タイトルを表示します。
@@ -279,14 +280,11 @@ "; -for ($row = 0; $row < $maxrows; $row++) { -$rowdata = pg_fetch_row($rs, $row); - + do { $tid = htmlspecialchars($rowdata[0]); $title = htmlspecialchars($rowdata[1]); - print "

\n"; -}//for + } while ($rowdata = $rs->fetch()); print "
".htmlspecialchars($rowdata[$col])."
$tid$title
\n"; }//if maxrows Index: trunk/install/php/reserveprogram.php =================================================================== --- trunk/install/php/reserveprogram.php (リビジョン 83) +++ trunk/install/php/reserveprogram.php (リビジョン 94) @@ -53,12 +53,12 @@ //タイトル取得 - $query = "select title from foltia_program where tid='$tid'"; - $rs = m_query($con, $query, "DBクエリに失敗しました"); - $maxrows = pg_num_rows($rs); - - if ($maxrows == 0) { + $query = "select title from foltia_program where tid = ? "; +// $rs = m_query($con, $query, "DBクエリに失敗しました"); +$rs = sql_query($con, $query, "DBクエリに失敗しました",array($tid)); +$rowdata = $rs->fetch(); +if (! $rowdata) { die_exit("登録番組がありません
"); } - $rowdata = pg_fetch_row($rs, 0); + $title = htmlspecialchars($rowdata[0]); ?> @@ -100,22 +100,19 @@ FROM foltia_subtitle , foltia_program ,foltia_station WHERE foltia_program.tid = foltia_subtitle.tid AND foltia_station.stationid = foltia_subtitle.stationid - AND foltia_program.tid ='$tid' + AND foltia_program.tid = ? ORDER BY stationrecch DESC "; - - $rs = m_query($con, $query, "DBクエリに失敗しました"); - $maxrows = pg_num_rows($rs); - - if ($maxrows == 0) { +// $rs = m_query($con, $query, "DBクエリに失敗しました"); +$rs = sql_query($con, $query, "DBクエリに失敗しました",array($tid)); +$rowdata = $rs->fetch(); +if (! $rowdata) { echo("放映局情報がまだはいってません
"); } else{ - $maxcols = pg_num_fields($rs); + $maxcols = $rs->columnCount(); echo("\n"); }//endif @@ -182,15 +179,15 @@ FROM foltia_subtitle , foltia_program ,foltia_station WHERE foltia_program.tid = foltia_subtitle.tid AND foltia_station.stationid = foltia_subtitle.stationid - AND foltia_subtitle.startdatetime >= '$now' AND foltia_program.tid ='$tid' + AND foltia_subtitle.startdatetime >= ? AND foltia_program.tid = ? ORDER BY foltia_subtitle.startdatetime ASC "; - $rs = m_query($con, $query, "DBクエリに失敗しました"); - $maxrows = pg_num_rows($rs); - - if ($maxrows == 0) { +// $rs = m_query($con, $query, "DBクエリに失敗しました"); +$rs = sql_query($con, $query, "DBクエリに失敗しました",array($now,$tid)); +$rowdata = $rs->fetch(); +if (! $rowdata) { echo("放映予定はありません
"); } else{ - $maxcols = pg_num_fields($rs); + $maxcols = $rs->columnCount(); ?> @@ -210,9 +207,6 @@ \n"); - /* pg_fetch_row で一行取り出す */ - $rowdata = pg_fetch_row($rs, $row); - for ($col = 0; $col < $maxcols; $col++) { /* 列に対応 */ if ($col == 3){ @@ -223,5 +217,5 @@ } echo("\n"); - } + } while ($rowdata = $rs->fetch()); }//end if ?> Index: trunk/install/php/foltialib.php =================================================================== --- trunk/install/php/foltialib.php (リビジョン 89) +++ trunk/install/php/foltialib.php (リビジョン 94) @@ -93,14 +93,5 @@ } } - - /* LIKE 用の文字列のエスケープ */ - function escape_like($sql, $quote = TRUE) { - return ($quote ? "'" : "") . - str_replace(array("\\\\", "%" , "_" ), - array("\\\\\\\\", "\\\\%", "\\\\_"), - pg_escape_string($sql)) . - ($quote ? "'" : ""); - } - + /* SQL 文字列のエスケープ */ function escape_string($sql, $quote = FALSE) { @@ -108,8 +99,18 @@ return "null"; } + if (preg_match("/^pgsql/", DSN)){ return ($quote ? "'" : "") . pg_escape_string($sql) . ($quote ? "'" : ""); - } + }else if (preg_match("/^sqlite/", DSN)){ + /* return ($quote ? "'" : "") . + sqlite_escape_string($sql) . + ($quote ? "'" : ""); + */ + return($sql); + }else{ + return "null"; + } + } /* SQL 数値のエスケープ */ @@ -124,41 +125,55 @@ } - /* PostgreSQL サーバに接続 */ + /* DBに接続 */ function m_connect() { -/* $con = @pg_connect("host=".DBHOST ." dbname=".DATABASE_NAME . - " user=".USER_NAME . - " password=".USER_PASSWORD); -*/ - $con = @pg_pconnect("host=".DBHOST ." dbname=".DATABASE_NAME . - " user=".USER_NAME . - " password=".USER_PASSWORD); - - - if (!$con) { - die_exit("データベースに接続出来ませんでした。"); + try { + $dbh = new PDO(DSN); + $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + return($dbh); + } catch (PDOException $e) { + die_exit($e->getMessage() . ": データベースに接続出来ませんでした。"); } /* データベースと、PHP の内部文字コードが違う場合 */ - return($con); } /* データベースとの接続を切り離す */ - function m_close($con) { - return @pg_close($con); - } - - /* SQL 文を実行 */ - function m_query($con, $query, $errmessage) { - $rtn = @pg_query($con, $query); - if (!$rtn) { +function m_close($dbh) { + return null; + } + +//旧関数 sql_queryに置き換え +function m_query($dbh, $query, $errmessage) { + try { + $rtn = $dbh->query($query); + return($rtn); + } catch (PDOException $e) { /* エラーメッセージに SQL 文を出すのはセキュリティ上良くない!! */ $msg = $errmessage . "
\n" . - @pg_last_error($con) . "
\n" . + $e->getMessage() . "
\n" . + var_export($e->errorInfo, true) . "
\n" . "" . htmlspecialchars($query) . "\n"; - $rtn = @pg_query($con, "rollback");//04.4.8 - m_close($con); +// $dbh->rollBack(); + $dbh = null; die_exit($msg); } + } +/* SQL 文を実行 */ +function sql_query($dbh, $query, $errmessage,$paramarray) { + try { + $rtn = $dbh->prepare("$query"); + $rtn->execute($paramarray); return($rtn); + } catch (PDOException $e) { + /* エラーメッセージに SQL 文を出すのはセキュリティ上良くない!! */ + $msg = $errmessage . "
\n" . + $e->getMessage() . "
\n" . + var_export($e->errorInfo, true) . "
\n" . + "" . htmlspecialchars($query) . + "\n"; +// $dbh->rollBack(); + $dbh = null; + die_exit($msg); + } } @@ -166,7 +181,8 @@ function m_showtable($rs) { /* 検索件数 */ - $maxrows = pg_num_rows($rs); + $maxrows = 0; - if ($maxrows == 0) { + $rowdata = $rs->fetch(); + if (! $rowdata) { echo("

データが存在しません

\n"); return 0; @@ -174,5 +190,5 @@ /* フィールド数 */ - $maxcols = pg_num_fields($rs); + $maxcols = $rs->columnCount(); ?>
@@ -183,5 +199,6 @@ for ($col = 1; $col < $maxcols; $col++) { /* pg_field_name() はフィールド名を返す */ - $f_name = htmlspecialchars(pg_field_name($rs, $col)); + $meta = $rs->getColumnMeta($col); + $f_name = htmlspecialchars($meta["name"]); echo("\n"); } @@ -192,8 +209,8 @@ \n"); - /* pg_fetch_row で一行取り出す */ - $rowdata = pg_fetch_row($rs, $row); /* 1列目にリンクを張る */ echo(" @@ -212,8 +229,10 @@ } - /* 指定したコードのデータを表示 */ - function m_viewdata($con, $code) { - /* コードに該当するデータを検索 */ - $query = " + +function m_viewdata($dbh, $code) { + +/*これ使ってないよね? + + $query = " select p.code ,p.name @@ -222,27 +241,28 @@ ,s.name as job ,p.profile - ,to_char(p.editdate, 'YYYY/MM/DD HH24:MI:SS') as editdate + ,datetime(p.editdate) as editdate from inet_profile p left join inet_job s on p.job = s.code where p.code = $code"; - $rs = m_query($con, $query, "個人情報の取得に失敗しました。"); - if (pg_num_rows($rs) == 0) { + $rs = m_query($dbh, $query, "個人情報の取得に失敗しました。"); + $rowdata = $rs->fetch(); + if (! $rowdata) { echo("

データが存在しません

\n"); return FALSE; } - /* フィールド数 */ - $maxcols = pg_num_fields($rs); - /* 先頭行 */ - $rowdata = pg_fetch_row($rs, 0); + // フィールド数 + $maxcols = $rs->columnCount(); ?>
$f_name\n"); - } + } while ($rowdata = $rs->fetch()); ?>
- + getColumnMeta(1); ?> + - + getColumnMeta($col); ?> - + @@ -250,8 +270,8 @@
fetch(); + if (! $rowdata) { print("番組データがありません
"); }else{ @@ -301,8 +321,5 @@ //print "\n"; print "\n"; @@ -429,6 +446,8 @@ global $recfolderpath,$recfolderpath; - exec ( "df -h $recfolderpath | grep $recfolderpath", $hdfreearea); - $freearea = preg_split ("/[\s,]+/", $hdfreearea[0]); +// exec ( "df -h $recfolderpath | grep $recfolderpath", $hdfreearea); +// $freearea = preg_split ("/[\s,]+/", $hdfreearea[0]); + exec ( "df -hP $recfolderpath", $hdfreearea); + $freearea = preg_split ("/[\s,]+/", $hdfreearea[count($hdfreearea)-1]); return $freearea; @@ -557,18 +576,20 @@ "; $useraccount = m_query($con, $query, "DBクエリに失敗しました"); - $useraccountrows = pg_num_rows($useraccount); - - if ($useraccountrows == 1 ){ - $rowdata = pg_fetch_row($useraccount, 0); + $rowdata = $useraccount->fetch(); + if (! $rowdata) { + header("HTTP/1.0 401 Unauthorized"); + redirectlogin(); + } + $memberid = $rowdata[0]; $userclass = $rowdata[1]; $username = $rowdata[2]; $dbpasswd = $rowdata[3]; - }else{ + + $rowdata = $useraccount->fetch(); + if ($rowdata) { header("HTTP/1.0 401 Unauthorized"); - //print ""; redirectlogin(); - }//end if - + } // passwdをdbから取りだし @@ -627,13 +648,17 @@ "; $useraccount = m_query($con, $query, "DBクエリに失敗しました"); - $useraccountrows = pg_num_rows($useraccount); - - if ($useraccountrows == 1 ){ - $rowdata = pg_fetch_row($useraccount, 0); - //$userclass = $rowdata[1]; - return ($rowdata[1]); - }else{ - return (99);//エラー - }//end if + $rowdata = $useraccount->fetch(); + if (! $rowdata) { + return (99); + } + + $userclass = $rowdata[1]; + + $rowdata = $useraccount->fetch(); + if ($rowdata) { + return (99); + } + + return ($userclass); }else{ @@ -655,13 +680,17 @@ "; $useraccount = m_query($con, $query, "DBクエリに失敗しました"); - $useraccountrows = pg_num_rows($useraccount); - - if ($useraccountrows == 1 ){ - $rowdata = pg_fetch_row($useraccount, 0); - //$userclass = $rowdata[1]; - return ($rowdata[0]); - }else{ + $rowdata = $useraccount->fetch(); + if (! $rowdata) { return (-1);//エラー - }//end if + } + + $memberid = $rowdata[0]; + + $rowdata = $useraccount->fetch(); + if ($rowdata) { + return (-1); + } + + return ($memberid); }else{ @@ -682,18 +711,21 @@ "; $useraccount = m_query($con, $query, "DBクエリに失敗しました"); - $useraccountrows = pg_num_rows($useraccount); - - if ($useraccountrows == 1 ){ - $rowdata = pg_fetch_row($useraccount, 0); - return ($rowdata[2]); + $rowdata = $useraccount->fetch(); + if (! $rowdata) { + return ("");//エラー + } + + $name = $rowdata[2]; + + $rowdata = $useraccount->fetch(); + if ($rowdata) { + return (""); + } + + return ($name); + }else{ - return ("");//エラー + return (""); }//end if - -}else{ - return (""); -}//end if - - }//end function getmemberid2name Index: trunk/install/php/selectcaptureimage.php =================================================================== --- trunk/install/php/selectcaptureimage.php (リビジョン 85) +++ trunk/install/php/selectcaptureimage.php (リビジョン 94) @@ -74,10 +74,11 @@ FROM foltia_subtitle , foltia_program ,foltia_station WHERE foltia_program.tid = foltia_subtitle.tid AND foltia_station.stationid = foltia_subtitle.stationid - AND foltia_subtitle.pid = '$pid' + AND foltia_subtitle.pid = ? "; - $rs = m_query($con, $query, "DBクエリに失敗しました"); -$rows = pg_num_rows($rs); -if ($rows == 0){ +// $rs = m_query($con, $query, "DBクエリに失敗しました"); +$rs = sql_query($con, $query, "DBクエリに失敗しました",array($pid)); +$rowdata = $rs->fetch(); +if (! $rowdata) { print "

キャプチャ画像


@@ -87,6 +88,4 @@ }else{ -$rowdata = pg_fetch_row($rs, 0); - print "

キャプチャ画像


Index: trunk/install/php/viewepg.php =================================================================== --- trunk/install/php/viewepg.php (リビジョン 91) +++ trunk/install/php/viewepg.php (リビジョン 94) @@ -91,9 +91,8 @@ $maxdisplay = 8; - $query = "SELECT stationid, stationname, stationrecch, ontvcode FROM foltia_station WHERE \"ontvcode\" ~~ '%ontvjapan%' - "; - $rs = m_query($con, $query, "DBクエリに失敗しました"); - $maxrows = pg_num_rows($rs); - +$query = "SELECT count(*) FROM foltia_station WHERE \"ontvcode\" LIKE '%ontvjapan%'"; +//$rs = m_query($con, $query, "DBクエリに失敗しました"); +$rs = sql_query($con, $query, "DBクエリに失敗しました"); +$maxrows = $rs->fetchColumn(0); if ($maxrows > $maxdisplay){ $pages = ceil($maxrows / $maxdisplay) ; @@ -138,13 +137,14 @@ $query = "SELECT stationid, stationname, stationrecch, ontvcode FROM foltia_station -WHERE \"ontvcode\" ~~ '%ontvjapan%' +WHERE \"ontvcode\" LIKE '%ontvjapan%' ORDER BY stationid ASC , stationrecch -OFFSET $offset LIMIT $maxdisplay +LIMIT ? OFFSET ? "; -$slistrs = m_query($con, $query, "DBクエリに失敗しました"); -$stations = pg_num_rows($slistrs); -for ($i=0 ; $i < $stations ; $i++){ - $rowdata = pg_fetch_row($slistrs, $i); - $stationhash[$i] = $rowdata[3] ; + +//$slistrs = m_query($con, $query, "DBクエリに失敗しました"); +$slistrs = sql_query($con, $query, "DBクエリに失敗しました",array($maxdisplay,$offset)); +while ($rowdata = $slistrs->fetch()) { + $stationhash[] = $rowdata[3]; + $snames[] = $rowdata[1]; // headder } @@ -158,34 +158,33 @@ SELECT ontvcode FROM foltia_station - WHERE \"ontvcode\" ~~ '%ontvjapan%' + WHERE \"ontvcode\" LIKE '%ontvjapan%' ORDER BY stationid ASC , stationrecch - OFFSET $offset LIMIT $maxdisplay + LIMIT ? OFFSET ? ) -AND startdatetime >= $start -AND startdatetime < $epgend +AND startdatetime >= ? +AND startdatetime < ? ORDER BY foltia_epg.startdatetime ASC "; -$rs = m_query($con, $query, "DBクエリに失敗しました"); +//$rs = m_query($con, $query, "DBクエリに失敗しました"); +$rs = sql_query($con, $query, "DBクエリに失敗しました",array($maxdisplay,$offset,$start,$epgend)); //print "$query
\n"; -$colmnums = pg_num_rows($rs); -if ($colmnums == 0){ +$rowdata = $rs->fetch(); +if (! $rowdata) { //番組データがない $colmnums = 2; }else{ - for ($i=0 ; $i < $colmnums ; $i++){ - $rowdata = pg_fetch_row($rs, $i); - $timetablehash["$rowdata[0]"] = ($i + 1); + $colmnums = 0; + do { + $colmnums++; + $timetablehash[$rowdata[0]] = $colmnums; // print "$rowdata[0]:$i+1
\n"; - } + } while ($rowdata = $rs->fetch()); } //print "colmnums $colmnums
\n"; //・局ごとに縦に配列入れていく -for ($j=0 ; $j < $stations ; $j++){ - $rowdata = pg_fetch_row($slistrs, $j); - $stationname = $rowdata[3]; - +foreach ($stationhash as $stationname) { $epgstart = $start ; $epgend = calcendtime($start , (8*60)); @@ -193,23 +192,18 @@ SELECT startdatetime , enddatetime , lengthmin , epgtitle , epgdesc , epgcategory ,ontvchannel ,epgid , epgcategory FROM foltia_epg -WHERE foltia_epg.ontvchannel = '$stationname' AND -enddatetime > $epgstart AND -startdatetime < $epgend +WHERE foltia_epg.ontvchannel = ? AND +enddatetime > ? AND +startdatetime < ? ORDER BY foltia_epg.startdatetime ASC "; - $statiodh = m_query($con, $query, "DBクエリに失敗しました"); - $maxrowsstation = pg_num_rows($statiodh); - -//print "maxrowsstation $maxrowsstation stationname $stationname
\n"; - -if ($maxrowsstation == 0) { + +// $statiodh = m_query($con, $query, "DBクエリに失敗しました"); + $statiodh = sql_query($con, $query, "DBクエリに失敗しました",array($stationname,$epgstart,$epgend)); + $stationrowdata = $statiodh->fetch(); + if (! $stationrowdata) { //print("番組データがありません
"); $item[0]["$stationname"] = ">番組データがありません"; }else{ - -for ($srow = 0; $srow < $maxrowsstation ; $srow++) { - -$stationrowdata = pg_fetch_row($statiodh, $srow); - + do { $printstarttime = substr($stationrowdata[0],8,2) . ":" . substr($stationrowdata[0],10,2); $tdclass = "t".substr($stationrowdata[0],8,2) . substr($stationrowdata[0],10,2); @@ -235,5 +229,5 @@ }//if -}//for + } while ($stationrowdata = $statiodh->fetch()); }//if @@ -291,13 +285,11 @@ //ヘッダ -for ($i=0;$i<$stations;$i++){ - $rowdata = pg_fetch_row($slistrs, $i); - print "".htmlspecialchars($rowdata[1])."" ; +foreach ($snames as $s) { + print "".htmlspecialchars($s)."" ; } //本体 for ($l = 0 ;$l < $colmnums; $l++){ print ""; - for ($m = 0 ; $m < $stations ; $m++ ){ - $stationname = $stationhash[$m]; + foreach ($stationhash as $stationname) { print_r($item[$l]["$stationname"]); } Index: trunk/install/php/listreserve.php =================================================================== --- trunk/install/php/listreserve.php (リビジョン 90) +++ trunk/install/php/listreserve.php (リビジョン 94) @@ -62,32 +62,20 @@ $query = " SELECT -foltia_program .tid, -stationname, -foltia_program .title, -foltia_subtitle.countno, -foltia_subtitle.subtitle, -foltia_subtitle.startdatetime , -foltia_subtitle.lengthmin , -foltia_tvrecord.bitrate , -foltia_subtitle.startoffset , -foltia_subtitle.pid , -foltia_subtitle.epgaddedby , + foltia_program.tid, stationname, foltia_program.title, + foltia_subtitle.countno, foltia_subtitle.subtitle, + foltia_subtitle.startdatetime as x, foltia_subtitle.lengthmin, + foltia_tvrecord.bitrate, foltia_subtitle.startoffset, + foltia_subtitle.pid, foltia_subtitle.epgaddedby, foltia_tvrecord.digital FROM foltia_subtitle , foltia_program ,foltia_station ,foltia_tvrecord WHERE 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 -AND foltia_subtitle.enddatetime >= '$now' +AND foltia_subtitle.enddatetime >= ? UNION SELECT -foltia_program .tid, -stationname, -foltia_program .title, -foltia_subtitle.countno, -foltia_subtitle.subtitle, -foltia_subtitle.startdatetime , -foltia_subtitle.lengthmin , -foltia_tvrecord.bitrate , -foltia_subtitle.startoffset , -foltia_subtitle.pid , -foltia_subtitle.epgaddedby , + foltia_program.tid, stationname, foltia_program.title, + foltia_subtitle.countno, foltia_subtitle.subtitle, + foltia_subtitle.startdatetime, foltia_subtitle.lengthmin, + foltia_tvrecord.bitrate, foltia_subtitle.startoffset, + foltia_subtitle.pid, foltia_subtitle.epgaddedby, foltia_tvrecord.digital FROM foltia_tvrecord @@ -96,10 +84,9 @@ LEFT OUTER JOIN foltia_station on (foltia_subtitle.stationid = foltia_station.stationid ) WHERE foltia_tvrecord.stationid = 0 AND -foltia_subtitle.enddatetime >= '$now' ORDER BY \"startdatetime\" ASC + foltia_subtitle.enddatetime >= ? ORDER BY x ASC "; - $rs = m_query($con, $query, "DBクエリに失敗しました"); - $maxrows = pg_num_rows($rs); - +// $rs = m_query($con, $query, "DBクエリに失敗しました"); + $rs = sql_query($con, $query, "DBクエリに失敗しました",array($now,$now)); //チューナー数 @@ -122,11 +109,10 @@ fetch(); + if (! $rowdata) { print "番組データがありません
\n"; }else{ - - /* フィールド数 */ - $maxcols = pg_num_fields($rs); + $maxcols = $rs->columnCount(); ?> @@ -149,8 +135,7 @@ \n"); - /* pg_fetch_row で一行取り出す */ - $rowdata = pg_fetch_row($rs, $row); + $pid = htmlspecialchars($rowdata[9]); @@ -168,32 +153,20 @@ $query = " SELECT -foltia_program .tid, -stationname, -foltia_program .title, -foltia_subtitle.countno, -foltia_subtitle.subtitle, -foltia_subtitle.startdatetime , -foltia_subtitle.lengthmin , -foltia_tvrecord.bitrate , -foltia_subtitle.startoffset , -foltia_subtitle.pid , -foltia_tvrecord.digital + foltia_program.tid, stationname, foltia_program.title, + foltia_subtitle.countno, foltia_subtitle.subtitle, + foltia_subtitle.startdatetime, foltia_subtitle.lengthmin, + foltia_tvrecord.bitrate, foltia_subtitle.startoffset, + foltia_subtitle.pid, foltia_tvrecord.digital FROM foltia_subtitle , foltia_program ,foltia_station ,foltia_tvrecord WHERE 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 -AND foltia_subtitle.enddatetime > '$rowdata[5]' -AND foltia_subtitle.startdatetime < '$endtime' +AND foltia_subtitle.enddatetime > ? +AND foltia_subtitle.startdatetime < ? UNION SELECT -foltia_program .tid, -stationname, -foltia_program .title, -foltia_subtitle.countno, -foltia_subtitle.subtitle, -foltia_subtitle.startdatetime , -foltia_subtitle.lengthmin , -foltia_tvrecord.bitrate , -foltia_subtitle.startoffset , -foltia_subtitle.pid , -foltia_tvrecord.digital + foltia_program.tid, stationname, foltia_program.title, + foltia_subtitle.countno, foltia_subtitle.subtitle, + foltia_subtitle.startdatetime, foltia_subtitle.lengthmin, + foltia_tvrecord.bitrate, foltia_subtitle.startoffset, + foltia_subtitle.pid, foltia_tvrecord.digital FROM foltia_tvrecord LEFT OUTER JOIN foltia_subtitle on (foltia_tvrecord.tid = foltia_subtitle.tid ) @@ -201,10 +174,12 @@ LEFT OUTER JOIN foltia_station on (foltia_subtitle.stationid = foltia_station.stationid ) WHERE foltia_tvrecord.stationid = 0 AND -foltia_subtitle.enddatetime > '$rowdata[5]' -AND foltia_subtitle.startdatetime < '$endtime' - "; +foltia_subtitle.enddatetime > ? +AND foltia_subtitle.startdatetime < ? +"; $rclass = ""; - $overlap = m_query($con, $query, "DBクエリに失敗しました"); - $overlapmaxrows = pg_num_rows($overlap); +// $overlap = m_query($con, $query, "DBクエリに失敗しました"); + $overlap = sql_query($con, $query, "DBクエリに失敗しました",array($rowdata[5],$endtime,$rowdata[5],$endtime)); + $owrowall = $overlap->fetchAll(); + $overlapmaxrows = count($owrowall); if ($overlapmaxrows > ($recunits) ){ @@ -212,5 +187,5 @@ for ($rrow = 0; $rrow < $overlapmaxrows ; $rrow++) { - $owrowdata = pg_fetch_array($overlap, $rrow); + $owrowdata = $owrowall[$rrow]; $owtimeline[ $owrowdata['startdatetime'] ] = $owtimeline[ $owrowdata['startdatetime'] ] +1; @@ -237,33 +212,21 @@ $query = " SELECT -foltia_program .tid, -stationname, -foltia_program .title, -foltia_subtitle.countno, -foltia_subtitle.subtitle, -foltia_subtitle.startdatetime , -foltia_subtitle.lengthmin , -foltia_tvrecord.bitrate , -foltia_subtitle.startoffset , -foltia_subtitle.pid , -foltia_tvrecord.digital + foltia_program.tid, stationname, foltia_program.title, + foltia_subtitle.countno, foltia_subtitle.subtitle, + foltia_subtitle.startdatetime, foltia_subtitle.lengthmin, + foltia_tvrecord.bitrate, foltia_subtitle.startoffset, + foltia_subtitle.pid, foltia_tvrecord.digital FROM foltia_subtitle , foltia_program ,foltia_station ,foltia_tvrecord WHERE 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 -AND foltia_subtitle.enddatetime > '$rowdata[5]' -AND foltia_subtitle.startdatetime < '$endtime' +AND foltia_subtitle.enddatetime > ? +AND foltia_subtitle.startdatetime < ? AND (foltia_station.stationrecch = '0' OR foltia_station.stationrecch = '-1' ) UNION SELECT -foltia_program .tid, -stationname, -foltia_program .title, -foltia_subtitle.countno, -foltia_subtitle.subtitle, -foltia_subtitle.startdatetime , -foltia_subtitle.lengthmin , -foltia_tvrecord.bitrate , -foltia_subtitle.startoffset , -foltia_subtitle.pid , -foltia_tvrecord.digital + foltia_program.tid, stationname, foltia_program.title, + foltia_subtitle.countno, foltia_subtitle.subtitle, + foltia_subtitle.startdatetime, foltia_subtitle.lengthmin, + foltia_tvrecord.bitrate, foltia_subtitle.startoffset, + foltia_subtitle.pid, foltia_tvrecord.digital FROM foltia_tvrecord LEFT OUTER JOIN foltia_subtitle on (foltia_tvrecord.tid = foltia_subtitle.tid ) @@ -271,11 +234,12 @@ LEFT OUTER JOIN foltia_station on (foltia_subtitle.stationid = foltia_station.stationid ) WHERE foltia_tvrecord.stationid = 0 AND -foltia_subtitle.enddatetime > '$rowdata[5]' -AND foltia_subtitle.startdatetime < '$endtime' +foltia_subtitle.enddatetime > ? +AND foltia_subtitle.startdatetime < ? AND (foltia_station.stationrecch = '0' OR foltia_station.stationrecch = '-1' ) - "; - $eoverlap = m_query($con, $query, "DBクエリに失敗しました"); - $eoverlapmaxrows = pg_num_rows($eoverlap); +// $eoverlap = m_query($con, $query, "DBクエリに失敗しました"); + $eoverlap = sql_query($con, $query, "DBクエリに失敗しました",array($rowdata[5], $endtime,$rowdata[5], $endtime)); + $eowrowall = $eoverlap->fetchAll(); + $eoverlapmaxrows = count($eowrowall); if ($eoverlapmaxrows > ($externalinputs) ){ @@ -283,5 +247,5 @@ for ($erow = 0; $erow < $eoverlapmaxrows ; $erow++) { - $eowrowdata = pg_fetch_array($eoverlap, $erow); + $eowrowdata = $eowrowall[$erow]; $eowtimeline[ $eowrowdata['startdatetime'] ] = $eowtimeline[ $eowrowdata['startdatetime'] ] +1; @@ -359,5 +323,5 @@ echo("
\n"); echo("\n"); - } + } while ($rowdata = $rs->fetch()); ?> @@ -374,14 +338,9 @@ fetch(); +if (! $rowdata) { //なければなにもしない }else{ - $maxcols = pg_num_fields($rs); + $maxcols = $rs->columnCount(); ?> @@ -417,8 +376,5 @@ "); }//if tid 0 - }//for + } while ($rowdata = $rs->fetch()); }//else ?> Index: trunk/install/php/index.php =================================================================== --- trunk/install/php/index.php (リビジョン 83) +++ trunk/install/php/index.php (リビジョン 94) @@ -67,34 +67,29 @@ WHERE foltia_tvrecord.tid = foltia_program.tid AND foltia_program.tid = foltia_subtitle.tid -AND foltia_subtitle.enddatetime >= '$now' +AND foltia_subtitle.enddatetime >= ? ORDER BY \"startdatetime\" ASC LIMIT 1000 "; - $reservedrssametid = m_query($con, $query, "DBクエリに失敗しました"); - $reservedmaxrowssameid = pg_num_rows($reservedrssametid); - - if ($reservedmaxrowssameid > 0 ){ - for ($rrow = 0; $rrow < $reservedmaxrowssameid ; $rrow++) { - $rowdata = pg_fetch_row($reservedrssametid, $rrow); +// $reservedrssametid = m_query($con, $query, "DBクエリに失敗しました"); +$reservedrssametid = sql_query($con, $query, "DBクエリに失敗しました",array($now)); +$rowdata = $reservedrssametid->fetch(); +if ($rowdata) { + do { $reservedpidsametid[] = $rowdata[7]; - } + } while ($rowdata = $reservedrssametid->fetch()); + $rowdata = ""; - $rrow = ""; }else{ - $reservedpidsametid = "" ; + $reservedpidsametid = array(); }//end if +$reservedrssametid->closeCursor(); //録画番組検索 $query = " SELECT -foltia_program .tid, -stationname, -foltia_program .title, -foltia_subtitle.countno, -foltia_subtitle.subtitle, -foltia_subtitle.startdatetime , -foltia_subtitle.lengthmin , -foltia_tvrecord.bitrate , -foltia_subtitle.pid + foltia_program.tid, stationname, foltia_program.title, + foltia_subtitle.countno, foltia_subtitle.subtitle, + foltia_subtitle.startdatetime as x, foltia_subtitle.lengthmin, + foltia_tvrecord.bitrate, foltia_subtitle.pid FROM foltia_subtitle , foltia_program ,foltia_station ,foltia_tvrecord WHERE 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 @@ -102,13 +97,8 @@ UNION SELECT -foltia_program .tid, -stationname, -foltia_program .title, -foltia_subtitle.countno, -foltia_subtitle.subtitle, -foltia_subtitle.startdatetime , -foltia_subtitle.lengthmin , -foltia_tvrecord.bitrate , -foltia_subtitle.pid + foltia_program.tid, stationname, foltia_program.title, + foltia_subtitle.countno, foltia_subtitle.subtitle, + foltia_subtitle.startdatetime, foltia_subtitle.lengthmin, + foltia_tvrecord.bitrate, foltia_subtitle.pid FROM foltia_tvrecord LEFT OUTER JOIN foltia_subtitle on (foltia_tvrecord.tid = foltia_subtitle.tid ) @@ -116,18 +106,41 @@ LEFT OUTER JOIN foltia_station on (foltia_subtitle.stationid = foltia_station.stationid ) WHERE foltia_tvrecord.stationid = 0 AND -foltia_subtitle.enddatetime >= '$now' ORDER BY \"startdatetime\" ASC -LIMIT 1000 - "; - - $reservedrs = m_query($con, $query, "DBクエリに失敗しました"); - $reservedmaxrows = pg_num_rows($reservedrs); - - if ($reservedmaxrows > 0 ){ - for ($rrow = 0; $rrow < $reservedmaxrows ; $rrow++) { - $rowdata = pg_fetch_row($reservedrs, $rrow); + foltia_subtitle.enddatetime >= '$now' ORDER BY x ASC +LIMIT 1000 + "; + +//$reservedrs = m_query($con, $query, "DBクエリに失敗しました"); +$query = " +SELECT + foltia_program.tid, stationname, foltia_program.title, + foltia_subtitle.countno, foltia_subtitle.subtitle, + foltia_subtitle.startdatetime as x, foltia_subtitle.lengthmin, + foltia_tvrecord.bitrate, foltia_subtitle.pid +FROM foltia_subtitle , foltia_program ,foltia_station ,foltia_tvrecord +WHERE 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 +AND foltia_subtitle.enddatetime >= ? +UNION +SELECT + foltia_program.tid, stationname, foltia_program.title, + foltia_subtitle.countno, foltia_subtitle.subtitle, + foltia_subtitle.startdatetime, foltia_subtitle.lengthmin, + foltia_tvrecord.bitrate, foltia_subtitle.pid +FROM foltia_tvrecord +LEFT OUTER JOIN foltia_subtitle on (foltia_tvrecord.tid = foltia_subtitle.tid ) +LEFT OUTER JOIN foltia_program on (foltia_tvrecord.tid = foltia_program.tid ) +LEFT OUTER JOIN foltia_station on (foltia_subtitle.stationid = foltia_station.stationid ) +WHERE foltia_tvrecord.stationid = 0 AND + foltia_subtitle.enddatetime >= ? ORDER BY x ASC +LIMIT 1000 + "; +$reservedrs = sql_query($con, $query, "DBクエリに失敗しました",array($now,$now)); + +$rowdata = $reservedrs->fetch(); +if ($rowdata) { + do { $reservedpid[] = $rowdata[8]; - } + } while ($rowdata = $reservedrs->fetch()); }else{ - $reservedpid = ""; + $reservedpid = array(); }//end if @@ -138,13 +151,8 @@ $query = " SELECT -foltia_program .tid, -stationname, -foltia_program .title, -foltia_subtitle.countno, -foltia_subtitle.subtitle, -foltia_subtitle.startdatetime , -foltia_subtitle.lengthmin , -foltia_subtitle.pid , -foltia_subtitle.startoffset + foltia_program.tid, stationname, foltia_program.title, + foltia_subtitle.countno, foltia_subtitle.subtitle, + foltia_subtitle.startdatetime, foltia_subtitle.lengthmin, + foltia_subtitle.pid, foltia_subtitle.startoffset FROM foltia_subtitle , foltia_program ,foltia_station WHERE foltia_program.tid = foltia_subtitle.tid AND foltia_station.stationid = foltia_subtitle.stationid @@ -153,20 +161,23 @@ LIMIT 1000 "; - $rs = m_query($con, $query, "DBクエリに失敗しました"); - $maxrows = pg_num_rows($rs); - - +$query = " + SELECT + foltia_program.tid, stationname, foltia_program.title, + foltia_subtitle.countno, foltia_subtitle.subtitle, + foltia_subtitle.startdatetime, foltia_subtitle.lengthmin, + foltia_subtitle.pid, foltia_subtitle.startoffset +FROM foltia_subtitle , foltia_program ,foltia_station +WHERE foltia_program.tid = foltia_subtitle.tid AND foltia_station.stationid = foltia_subtitle.stationid + AND foltia_subtitle.enddatetime >= ? AND foltia_subtitle.countno = '1' +ORDER BY foltia_subtitle.startdatetime ASC +LIMIT 1000 + "; }else{ - $query = " +$query = " SELECT -foltia_program .tid, -stationname, -foltia_program .title, -foltia_subtitle.countno, -foltia_subtitle.subtitle, -foltia_subtitle.startdatetime , -foltia_subtitle.lengthmin , -foltia_subtitle.pid , -foltia_subtitle.startoffset + foltia_program.tid, stationname, foltia_program.title, + foltia_subtitle.countno, foltia_subtitle.subtitle, + foltia_subtitle.startdatetime, foltia_subtitle.lengthmin, + foltia_subtitle.pid, foltia_subtitle.startoffset FROM foltia_subtitle , foltia_program ,foltia_station WHERE foltia_program.tid = foltia_subtitle.tid AND foltia_station.stationid = foltia_subtitle.stationid @@ -175,10 +186,22 @@ LIMIT 1000 "; - $rs = m_query($con, $query, "DBクエリに失敗しました"); - $maxrows = pg_num_rows($rs); - +$query = " + SELECT + foltia_program.tid, stationname, foltia_program.title, + foltia_subtitle.countno, foltia_subtitle.subtitle, + foltia_subtitle.startdatetime, foltia_subtitle.lengthmin, + foltia_subtitle.pid, foltia_subtitle.startoffset +FROM foltia_subtitle , foltia_program ,foltia_station +WHERE foltia_program.tid = foltia_subtitle.tid AND foltia_station.stationid = foltia_subtitle.stationid + AND foltia_subtitle.enddatetime >= ? +ORDER BY foltia_subtitle.startdatetime ASC +LIMIT 1000 + "; }//end if -if ($maxrows == 0) { +//$rs = m_query($con, $query, "DBクエリに失敗しました"); +$rs = sql_query($con, $query, "DBクエリに失敗しました",array($now)); +$rowdata = $rs->fetch(); +if (! $rowdata) { header("Status: 404 Not Found",TRUE,404); printtitle(); @@ -211,5 +234,5 @@ columnCount(); ?>
@@ -230,8 +253,5 @@ \n"); - } + } while ($rowdata = $rs->fetch()); ?> Index: trunk/install/php/StarlightBreaker/sb-edit.php =================================================================== --- trunk/install/php/StarlightBreaker/sb-edit.php (リビジョン 88) +++ trunk/install/php/StarlightBreaker/sb-edit.php (リビジョン 94) @@ -73,8 +73,8 @@ FROM foltia_subtitle , foltia_program ,foltia_station WHERE foltia_program.tid = foltia_subtitle.tid AND foltia_station.stationid = foltia_subtitle.stationid - AND foltia_subtitle.pid = '$pid' - - "; - $rs = m_query($con, $query, "DBクエリに失敗しました"); +AND foltia_subtitle.pid = ? +"; +// $rs = m_query($con, $query, "DBクエリに失敗しました"); + $rs = sql_query($con, $query, "DBクエリに失敗しました",array($pid)); $rows = pg_num_rows($rs); if ($rows == 0){ Index: trunk/install/php/reserveepg.php =================================================================== --- trunk/install/php/reserveepg.php (リビジョン 70) +++ trunk/install/php/reserveepg.php (リビジョン 94) @@ -56,13 +56,13 @@ stationname , stationrecch ,stationid FROM foltia_epg , foltia_station - WHERE epgid='$epgid' AND foltia_station.ontvcode = foltia_epg.ontvchannel + WHERE epgid = ? AND foltia_station.ontvcode = foltia_epg.ontvchannel ";//4812 - $rs = m_query($con, $query, "DBクエリに失敗しました"); - $maxrows = pg_num_rows($rs); - - if ($maxrows == 0) { +// $rs = m_query($con, $query, "DBクエリに失敗しました"); + $rs = sql_query($con, $query, "DBクエリに失敗しました",array($epgid)); +$rowdata = $rs->fetch(); +if (! $rowdata) { die_exit("登録番組がありません
"); } - $rowdata = pg_fetch_row($rs, 0); + //$title = htmlspecialchars($rowdata[0]); ?> @@ -136,33 +136,21 @@ $query = " SELECT -foltia_program .title, -foltia_program .tid, -stationname, -foltia_station.stationid , -foltia_subtitle.countno, -foltia_subtitle.subtitle, -foltia_subtitle.startdatetime , -foltia_subtitle.lengthmin , -foltia_tvrecord.bitrate , -foltia_subtitle.startoffset , -foltia_subtitle.pid + foltia_program.title, foltia_program.tid, stationname, + foltia_station.stationid, foltia_subtitle.countno, + foltia_subtitle.subtitle, foltia_subtitle.startdatetime, + foltia_subtitle.lengthmin, foltia_tvrecord.bitrate, + foltia_subtitle.startoffset, foltia_subtitle.pid FROM foltia_subtitle , foltia_program ,foltia_station ,foltia_tvrecord WHERE 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 -AND foltia_subtitle.startdatetime ='$startfoltime' -AND foltia_subtitle.enddatetime = '$endfoltime' -AND foltia_station.stationid = '$stationid' +AND foltia_subtitle.startdatetime = ? +AND foltia_subtitle.enddatetime = ? +AND foltia_station.stationid = ? UNION SELECT -foltia_program .title, -foltia_program .tid, -stationname, -foltia_station.stationid , -foltia_subtitle.countno, -foltia_subtitle.subtitle, -foltia_subtitle.startdatetime , -foltia_subtitle.lengthmin , -foltia_tvrecord.bitrate , -foltia_subtitle.startoffset , -foltia_subtitle.pid + foltia_program.title, foltia_program.tid, stationname, + foltia_station.stationid, foltia_subtitle.countno, + foltia_subtitle.subtitle, foltia_subtitle.startdatetime, + foltia_subtitle.lengthmin, foltia_tvrecord.bitrate, + foltia_subtitle.startoffset, foltia_subtitle.pid FROM foltia_tvrecord LEFT OUTER JOIN foltia_subtitle on (foltia_tvrecord.tid = foltia_subtitle.tid ) @@ -170,23 +158,20 @@ LEFT OUTER JOIN foltia_station on (foltia_subtitle.stationid = foltia_station.stationid ) WHERE foltia_tvrecord.stationid = 0 -AND foltia_subtitle.startdatetime ='$startfoltime' -AND foltia_subtitle.enddatetime = '$endfoltime' -AND foltia_station.stationid = '$stationid' +AND foltia_subtitle.startdatetime = ? +AND foltia_subtitle.enddatetime = ? +AND foltia_station.stationid = ? "; - - - $rs = m_query($con, $query, "DBクエリに失敗しました"); - $maxrows = pg_num_rows($rs); - //print ""; print "\n"; - if ($maxrows == 0) { +//$rs = m_query($con, $query, "DBクエリに失敗しました"); +$rs = sql_query($con, $query, "DBクエリに失敗しました",array($startfoltime,$endfoltime,$stationid,$startfoltime,$endfoltime,$stationid)); +$chkoverwrap = $rs->fetch(); +if (! $chkoverwrap) { //重複なし print "
\n"; }else{ - $chkoverwrap = pg_fetch_row($rs, 0); $prereservedtitle = htmlspecialchars($chkoverwrap[0]); $tid = htmlspecialchars($chkoverwrap[1]); Index: trunk/install/php/showlib.php =================================================================== --- trunk/install/php/showlib.php (リビジョン 83) +++ trunk/install/php/showlib.php (リビジョン 94) @@ -84,9 +84,8 @@ "; -$rs = m_query($con, $query, "DBクエリに失敗しました"); - -$maxrows = pg_num_rows($rs); - -if ($maxrows > 0 ){ +//$rs = m_query($con, $query, "DBクエリに失敗しました"); +$rs = sql_query($con, $query, "DBクエリに失敗しました"); +$rowdata = $rs->fetch(); +if ($rowdata) { if(ereg("iPhone",$useragent)){ print "