チケット #8: foltia-sqlite.diff

ファイル foltia-sqlite.diff, 128.3 kB (登録者: guest, 登録時期: 15 年 前)

r91へのパッチ

  • foltia/install/mktable.sqlite.txt

    old new  
     1 
     2drop table  foltia_program ; 
     3 
     4create table foltia_program ( 
     5tid integer PRIMARY KEY,  
     6title text , 
     7startweektype text, 
     8starttime text, 
     9lengthmin integer, 
     10firstlight text, 
     11officialuri text ,  
     12aspect integer ,  
     13psp integer ,  
     14transfer text, 
     15PSPdirname text  
     16); 
     17create unique index foltia_program_tid_index on foltia_program (tid); 
     18 
     19-- REVOKE ALL on "foltia_program" from PUBLIC; 
     20-- GRANT UPDATE,SELECT,INSERT on "foltia_program" to "foltia"; 
     21 
     22drop table  foltia_subtitle ; 
     23 
     24create table foltia_subtitle ( 
     25pid integer  PRIMARY KEY, 
     26tid integer,  
     27stationid integer, 
     28countno integer, 
     29subtitle text, 
     30startdatetime integer, 
     31enddatetime integer, 
     32startoffset integer, 
     33lengthmin integer, 
     34m2pfilename text , 
     35PSPfilename text , 
     36epgaddedby integer ,  
     37lastupdate timestamp, 
     38filestatus integer 
     39); 
     40create unique index foltia_subtitle_pid_index on foltia_subtitle (pid); 
     41create  index foltia_subtitle_tid_index on foltia_subtitle (tid); 
     42create  index foltia_subtitle_stationid_index on foltia_subtitle (stationid); 
     43create  index foltia_subtitle_enddatetime_index on foltia_subtitle (enddatetime); 
     44create  index foltia_subtitle_startdatetime_index on foltia_subtitle (startdatetime); 
     45 
     46-- REVOKE ALL on "foltia_subtitle" from PUBLIC; 
     47-- GRANT UPDATE,SELECT,INSERT on "foltia_subtitle" to "foltia"; 
     48 
     49drop table foltia_tvrecord; 
     50create table foltia_tvrecord ( 
     51tid integer  , 
     52stationid integer, 
     53bitrate integer , 
     54digital integer 
     55); 
     56create  index foltia_tvrecord_tid_index on foltia_tvrecord (tid); 
     57 
     58-- REVOKE ALL on "foltia_tvrecord" from PUBLIC; 
     59-- GRANT ALL on "foltia_tvrecord" to "foltia"; 
     60 
     61 
     62drop table foltia_epg; 
     63create table foltia_epg ( 
     64epgid integer   PRIMARY KEY, 
     65startdatetime integer, 
     66enddatetime integer, 
     67lengthmin integer , 
     68ontvchannel text, 
     69epgtitle text, 
     70epgdesc text, 
     71epgcategory text  
     72); 
     73create  index foltia_epg_startdatetime_index on foltia_epg (startdatetime); 
     74create  index foltia_epg_enddatetime_index on foltia_epg (enddatetime); 
     75create  index foltia_epg_ontvchannel_index on foltia_epg (ontvchannel); 
     76 
     77-- REVOKE ALL on "foltia_epg" from PUBLIC; 
     78-- GRANT ALL on "foltia_epg" to "foltia"; 
     79 
     80drop table foltia_m2pfiles; 
     81create table foltia_m2pfiles ( 
     82m2pfilename text  
     83); 
     84-- REVOKE ALL on "foltia_m2pfiles" from PUBLIC; 
     85-- GRANT ALL on "foltia_m2pfiles" to "foltia"; 
     86 
     87drop table foltia_mp4files; 
     88create table foltia_mp4files ( 
     89tid integer, 
     90mp4filename text  
     91); 
     92-- REVOKE ALL on "foltia_mp4files" from PUBLIC; 
     93-- GRANT ALL on "foltia_mp4files" to "foltia"; 
     94 
     95drop table foltia_station; 
     96CREATE TABLE foltia_station ( 
     97    stationid integer  PRIMARY KEY, 
     98    stationname text, 
     99    stationrecch integer, 
     100    stationcallsign text, 
     101    stationuri text, 
     102    tunertype text, 
     103    tunerch text, 
     104    device text, 
     105    ontvcode text, 
     106        digitalch integer, 
     107        digitalstationband integer 
     108); 
     109--    ADD CONSTRAINT foltia_station_pkey PRIMARY KEY (stationid); 
     110-- REVOKE ALL on "foltia_station" from PUBLIC; 
     111-- GRANT ALL on "foltia_station" to "foltia"; 
     112 
     113-- 
     114-- PostgreSQL database dump 
     115-- 
     116 
     117-- SET client_encoding = 'EUC_JP'; 
     118-- SET check_function_bodies = false; 
     119 
     120-- SET SESSION AUTHORIZATION 'foltia'; 
     121 
     122-- SET search_path = public, pg_catalog; 
     123 
     124-- 
     125-- TOC entry 3 (OID 17158) 
     126-- Name: foltia_station; Type: TABLE; Schema: public; Owner: foltia 
     127-- 
     128 
     129-- 
     130-- TOC entry 4 (OID 17158) 
     131-- Name: foltia_station; Type: ACL; Schema: public; Owner: foltia 
     132-- 
     133 
     134 
     135-- SET SESSION AUTHORIZATION 'foltia'; 
     136 
     137-- 
     138-- Data for TOC entry 6 (OID 17158) 
     139-- Name: foltia_station; Type: TABLE DATA; Schema: public; Owner: foltia 
     140-- 
     141INSERT INTO foltia_program VALUES (0, 'EPG録画', '', '', NULL, '', '', 3, 1, '', ''); 
     142INSERT INTO foltia_tvrecord VALUES (0,0,5,1); 
     143 
     144 
     145 
     146INSERT INTO foltia_station VALUES (0, '[全局]', 0, '', '', '', '', '', '',NULL,NULL); 
     147INSERT INTO foltia_station VALUES (1, 'NHK総合', 1, 'NHK', '', NULL, NULL, NULL, '0031.ontvjapan.com',27,0); 
     148INSERT INTO foltia_station VALUES (3, 'NHK教育', 3, 'ETV', '', NULL, NULL, NULL, '0041.ontvjapan.com',26,0); 
     149INSERT INTO foltia_station VALUES (4, '日本テレビ', 4, 'NTV', '', NULL, NULL, NULL, '0004.ontvjapan.com',25,0); 
     150INSERT INTO foltia_station VALUES (6, 'TBS', 6, 'TBS', '', NULL, NULL, NULL, '0005.ontvjapan.com',22,0); 
     151INSERT INTO foltia_station VALUES (8, 'フジテレビ', 8, 'CX', '', NULL, NULL, NULL, '0006.ontvjapan.com',21,0); 
     152INSERT INTO foltia_station VALUES (10, 'テレビ朝日', 10, 'EX', '', NULL, NULL, NULL, '0007.ontvjapan.com',24,0); 
     153INSERT INTO foltia_station VALUES (12, 'テレビ東京', 12, 'TX', '', NULL, NULL, NULL, '0008.ontvjapan.com',23,0); 
     154INSERT INTO foltia_station VALUES (42, 'tvk', 42, 'TVK', '', '', '', '', '0009.ontvjapan.com',18,0); 
     155INSERT INTO foltia_station VALUES (14, 'TOKYO MX', 14, 'MX', '', '', '', '', '0016.ontvjapan.com',20,0); 
     156INSERT INTO foltia_station VALUES (46, 'チバテレビ', -10, 'CTC', '', NULL, NULL, NULL, NULL,30,0); 
     157INSERT INTO foltia_station VALUES (38, 'テレ玉', -10, 'TVS', '', NULL, NULL, NULL, NULL,32,0); 
     158INSERT INTO foltia_station VALUES (418, '放送大学', -10, 'UAIR', '', NULL, NULL, NULL, '0013.ontvjapan.com',28,0); 
     159INSERT INTO foltia_station VALUES (101, 'NHK-BS1', 0, 'BS7', '', '', '101', '', '3001.ontvjapan.com',101,1); 
     160INSERT INTO foltia_station VALUES (102, 'NHK-BS2', 0, 'BS11', '', '', '102', '', '3002.ontvjapan.com',102,1); 
     161INSERT INTO foltia_station VALUES (103, 'NHK-BShi', 0, '', '', '', '103', '', '3003.ontvjapan.com',103,1); 
     162INSERT INTO foltia_station VALUES (409, 'BS日テレ', 0, '', '', '', '141', '', '3004.ontvjapan.com',141,1); 
     163INSERT INTO foltia_station VALUES (384, 'BS朝日', 0, '', '', '', '151', '', '3005.ontvjapan.com',151,1); 
     164INSERT INTO foltia_station VALUES (161, 'BS-i', 0, '', '', '', '161', '', '3006.ontvjapan.com',161,1); 
     165INSERT INTO foltia_station VALUES (389, 'BS Japan', 0, '', '', '', '171', '','3007.ontvjapan.com',171,1); 
     166INSERT INTO foltia_station VALUES (381, 'BSフジ', 0, '', '', '', '181', '', '3008.ontvjapan.com',181,1); 
     167INSERT INTO foltia_station VALUES (191, 'WOWOW', 0, 'BS5', '', '', '191', '', '3009.ontvjapan.com',191,1); 
     168INSERT INTO foltia_station VALUES (420, 'WOWOW2', 0, '', '', '', '192', '', '3010.ontvjapan.com',192,1); 
     169INSERT INTO foltia_station VALUES (421, 'WOWOW3', 0, '', '', '', '193', '', '3011.ontvjapan.com',193,1); 
     170INSERT INTO foltia_station VALUES (468, 'BS11デジタル', 0, '', '', '', '211', '', '',211,1); 
     171INSERT INTO foltia_station VALUES (408, 'ファミリー劇場', 0, '', '', '', '751', '', '1015.ontvjapan.com',NULL,NULL); 
     172INSERT INTO foltia_station VALUES (397, 'カートゥーンネットワーク', 0, '', '', '', '780', '', '1046.ontvjapan.com',NULL,NULL); 
     173INSERT INTO foltia_station VALUES (263, 'アニマックス', 0, '', '', '', '782', '', '1047.ontvjapan.com',NULL,NULL); 
     174INSERT INTO foltia_station VALUES (261, 'キッズステーション', 0, '', '', 'c', '781', '', '1045.ontvjapan.com',NULL,NULL); 
     175INSERT INTO foltia_station VALUES (449, 'ディスカバリーチャンネル', 0, '', '', '', '796', '', '1062.ontvjapan.com',NULL,NULL); 
     176INSERT INTO foltia_station VALUES (448, 'MONDO21', 0, '', '', '', '722', '', '1049.ontvjapan.com',NULL,NULL); 
     177INSERT INTO foltia_station VALUES (401, 'チャンネルNECO', 0, '', '', '', '750', '', '1008.ontvjapan.com',NULL,NULL); 
     178INSERT INTO foltia_station VALUES (455, '330ch WOWOW', -10, NULL, NULL, NULL, NULL, NULL, NULL,NULL,NULL); 
     179INSERT INTO foltia_station VALUES (480, 'TBSラジオ(954)', -10, NULL, NULL, NULL, NULL, NULL, NULL,NULL,NULL); 
     180INSERT INTO foltia_station VALUES (477, '北海道文化放送', -10, NULL, NULL, NULL, NULL, NULL, NULL,NULL,NULL); 
     181INSERT INTO foltia_station VALUES (463, 'gooアニメ', -10, NULL, NULL, NULL, NULL, NULL, NULL,NULL,NULL); 
     182INSERT INTO foltia_station VALUES (461, '@nifty', -10, '', '', '', '', '', '',NULL,NULL); 
     183INSERT INTO foltia_station VALUES (466, 'NHKラジオ第一', -10, NULL, NULL, NULL, NULL, NULL, NULL,NULL,NULL); 
     184INSERT INTO foltia_station VALUES (474, '日テレプラス', -10, NULL, NULL, NULL, NULL, NULL, NULL,NULL,NULL); 
     185INSERT INTO foltia_station VALUES (476, 'ニコニコアニメチャンネル', -10, NULL, NULL, NULL, NULL, NULL, NULL,NULL,NULL); 
     186INSERT INTO foltia_station VALUES (451, 'RKB毎日放送', -10, NULL, NULL, NULL, NULL, NULL, NULL,NULL,NULL); 
     187INSERT INTO foltia_station VALUES (452, '北海道放送', -10, NULL, NULL, NULL, NULL, NULL, NULL,NULL,NULL); 
     188INSERT INTO foltia_station VALUES (454, 'テレビ和歌山', -10, NULL, NULL, NULL, NULL, NULL, NULL,NULL,NULL); 
     189INSERT INTO foltia_station VALUES (456, '静岡放送', -10, NULL, NULL, NULL, NULL, NULL, NULL,NULL,NULL); 
     190INSERT INTO foltia_station VALUES (457, 'i-revo', -10, NULL, NULL, NULL, NULL, NULL, NULL,NULL,NULL); 
     191INSERT INTO foltia_station VALUES (459, '東北放送', -10, NULL, NULL, NULL, NULL, NULL, NULL,NULL,NULL); 
     192INSERT INTO foltia_station VALUES (464, 'テレビ山口', -10, NULL, NULL, NULL, NULL, NULL, NULL,NULL,NULL); 
     193INSERT INTO foltia_station VALUES (478, '札幌テレビ放送', -10, NULL, NULL, NULL, NULL, NULL, NULL,NULL,NULL); 
     194INSERT INTO foltia_station VALUES (395, 'カミングスーンTV', -10, '', '', '', '', '', '',NULL,NULL); 
     195INSERT INTO foltia_station VALUES (443, 'スーパーチャンネル', -10, '', '', '', '', '', '',NULL,NULL); 
     196INSERT INTO foltia_station VALUES (385, 'TBSチャンネル', 0, '', '', '', '765', '', '',NULL,NULL); 
     197INSERT INTO foltia_station VALUES (462, '瀬戸内海放送', -10, '', '', '', '', '', '',NULL,NULL); 
     198INSERT INTO foltia_station VALUES (473, 'フジCSHD', -10, NULL, NULL, NULL, NULL, NULL, NULL,NULL,NULL); 
     199INSERT INTO foltia_station VALUES (475, 'スカパー181ch', -10, NULL, NULL, NULL, NULL, NULL, NULL,NULL,NULL); 
     200INSERT INTO foltia_station VALUES (479, '北海道テレビ放送', -10, NULL, NULL, NULL, NULL, NULL, NULL,NULL,NULL); 
     201INSERT INTO foltia_station VALUES (450, 'NHK教育3', -10, NULL, NULL, NULL, NULL, NULL, NULL,NULL,NULL); 
     202INSERT INTO foltia_station VALUES (453, 'バンダイチャンネルキッズ', -10, NULL, NULL, NULL, NULL, NULL, NULL,NULL,NULL); 
     203INSERT INTO foltia_station VALUES (458, '日テレプラス&サイエンス', -10, NULL, NULL, NULL, NULL, NULL, NULL,NULL,NULL); 
     204INSERT INTO foltia_station VALUES (460, 'ビクトリーチャンネル', -10, NULL, NULL, NULL, NULL, NULL, NULL,NULL,NULL); 
     205INSERT INTO foltia_station VALUES (472, 'ytv', -10, NULL, NULL, NULL, NULL, NULL, NULL,NULL,NULL); 
     206INSERT INTO foltia_station VALUES (422, '東海テレビ', -10, '', '', '', '', '', '',NULL,NULL); 
     207INSERT INTO foltia_station VALUES (423, 'ShowTime', -10, '', '', '', '', '', '',NULL,NULL); 
     208INSERT INTO foltia_station VALUES (424, 'メ〜テレ', -10, NULL, NULL, NULL, NULL, NULL, NULL,NULL,NULL); 
     209INSERT INTO foltia_station VALUES (425, '三重テレビ', -10, NULL, NULL, NULL, NULL, NULL, NULL,NULL,NULL); 
     210INSERT INTO foltia_station VALUES (426, '中京テレビ', -10, NULL, NULL, NULL, NULL, NULL, NULL,NULL,NULL); 
     211INSERT INTO foltia_station VALUES (293, 'AT-X', -10, '', '', NULL, NULL, NULL, NULL,NULL,NULL); 
     212INSERT INTO foltia_station VALUES (295, 'フジ721', -10, '', '', NULL, NULL, NULL, NULL,NULL,NULL); 
     213INSERT INTO foltia_station VALUES (380, 'スカパー180ch', -10, '', '', NULL, NULL, NULL, NULL,NULL,NULL); 
     214INSERT INTO foltia_station VALUES (427, '岐阜放送', -10, NULL, NULL, NULL, NULL, NULL, NULL,NULL,NULL); 
     215INSERT INTO foltia_station VALUES (428, 'テレビ新広島', -10, NULL, NULL, NULL, NULL, NULL, NULL,NULL,NULL); 
     216INSERT INTO foltia_station VALUES (383, 'サンテレビ', -10, '', '', NULL, NULL, NULL, NULL,NULL,NULL); 
     217INSERT INTO foltia_station VALUES (429, 'CBCテレビ', -10, NULL, NULL, NULL, NULL, NULL, NULL,NULL,NULL); 
     218INSERT INTO foltia_station VALUES (386, 'テレ朝チャンネル', -10, '', '', NULL, NULL, NULL, NULL,NULL,NULL); 
     219INSERT INTO foltia_station VALUES (390, 'サンテレビジョン', -10, '', '', NULL, NULL, NULL, NULL,NULL,NULL); 
     220INSERT INTO foltia_station VALUES (392, 'スカパー183ch', -10, '', '', NULL, NULL, NULL, NULL,NULL,NULL); 
     221INSERT INTO foltia_station VALUES (394, 'スカパー160ch', -10, '', '', NULL, NULL, NULL, NULL,NULL,NULL); 
     222INSERT INTO foltia_station VALUES (396, 'KBS京都', -10, '', '', NULL, NULL, NULL, NULL,NULL,NULL); 
     223INSERT INTO foltia_station VALUES (398, 'テレビ大阪', -10, '', '', NULL, NULL, NULL, NULL,NULL,NULL); 
     224INSERT INTO foltia_station VALUES (399, 'ABCテレビ', -10, '', '', NULL, NULL, NULL, NULL,NULL,NULL); 
     225INSERT INTO foltia_station VALUES (400, 'なし', -10, '', '', NULL, NULL, NULL, NULL,NULL,NULL); 
     226INSERT INTO foltia_station VALUES (402, '関西テレビ', -10, '', '', NULL, NULL, NULL, NULL,NULL,NULL); 
     227INSERT INTO foltia_station VALUES (406, 'MBS毎日放送', -10, '', '', NULL, NULL, NULL, NULL,NULL,NULL); 
     228INSERT INTO foltia_station VALUES (407, 'animate.tv', -10, '', '', NULL, NULL, NULL, NULL,NULL,NULL); 
     229INSERT INTO foltia_station VALUES (410, 'テレビ愛知', -10, '', '', NULL, NULL, NULL, NULL,NULL,NULL); 
     230INSERT INTO foltia_station VALUES (411, 'インターネット', -10, '', '', NULL, NULL, NULL, NULL,NULL,NULL); 
     231INSERT INTO foltia_station VALUES (413, 'よみうりテレビ', -10, '', '', NULL, NULL, NULL, NULL,NULL,NULL); 
     232INSERT INTO foltia_station VALUES (414, 'LFX488', -10, '', '', NULL, NULL, NULL, NULL,NULL,NULL); 
     233INSERT INTO foltia_station VALUES (415, 'LFX', -10, '', '', NULL, NULL, NULL, NULL,NULL,NULL); 
     234INSERT INTO foltia_station VALUES (416, 'LFX BB', -10, '', '', NULL, NULL, NULL, NULL,NULL,NULL); 
     235INSERT INTO foltia_station VALUES (419, 'GyaO', -10, '', '', NULL, NULL, NULL, NULL,NULL,NULL); 
     236INSERT INTO foltia_station VALUES (417, 'とちぎテレビ', -10, 'TTV', '', NULL, NULL, NULL, NULL,NULL,NULL); 
     237INSERT INTO foltia_station VALUES (412, '群馬テレビ', -10, 'GTV', '', NULL, NULL, NULL, NULL,NULL,NULL); 
     238INSERT INTO foltia_station VALUES (430, '奈良テレビ', -10, NULL, NULL, NULL, NULL, NULL, NULL,NULL,NULL); 
     239INSERT INTO foltia_station VALUES (431, 'TVQ九州放送', -10, NULL, NULL, NULL, NULL, NULL, NULL,NULL,NULL); 
     240INSERT INTO foltia_station VALUES (432, 'テレビ北海道', -10, NULL, NULL, NULL, NULL, NULL, NULL,NULL,NULL); 
     241INSERT INTO foltia_station VALUES (433, 'BIGLOBEストリーム', -10, NULL, NULL, NULL, NULL, NULL, NULL,NULL,NULL); 
     242INSERT INTO foltia_station VALUES (434, 'テレビせとうち', -10, NULL, NULL, NULL, NULL, NULL, NULL,NULL,NULL); 
     243INSERT INTO foltia_station VALUES (435, '中国放送', -10, NULL, NULL, NULL, NULL, NULL, NULL,NULL,NULL); 
     244INSERT INTO foltia_station VALUES (436, '文化放送(1134)', -10, NULL, NULL, NULL, NULL, NULL, NULL,NULL,NULL); 
     245INSERT INTO foltia_station VALUES (437, '広島ホームテレビ', -10, NULL, NULL, NULL, NULL, NULL, NULL,NULL,NULL); 
     246INSERT INTO foltia_station VALUES (438, '広島テレビ', -10, NULL, NULL, NULL, NULL, NULL, NULL,NULL,NULL); 
     247INSERT INTO foltia_station VALUES (439, '岡山放送', -10, NULL, NULL, NULL, NULL, NULL, NULL,NULL,NULL); 
     248INSERT INTO foltia_station VALUES (440, '山陽放送', -10, NULL, NULL, NULL, NULL, NULL, NULL,NULL,NULL); 
     249INSERT INTO foltia_station VALUES (441, 'びわ湖放送', -10, NULL, NULL, NULL, NULL, NULL, NULL,NULL,NULL); 
     250INSERT INTO foltia_station VALUES (442, 'NHK-FM', -10, NULL, NULL, NULL, NULL, NULL, NULL,NULL,NULL); 
     251INSERT INTO foltia_station VALUES (444, 'バンダイチャンネル', -10, NULL, NULL, NULL, NULL, NULL, NULL,NULL,NULL); 
     252INSERT INTO foltia_station VALUES (445, 'フレッツ・スクウェア(NTT東日本)', -10, NULL, NULL, NULL, NULL, NULL, NULL,NULL,NULL); 
     253INSERT INTO foltia_station VALUES (446, 'フジ739', -10, NULL, NULL, NULL, NULL, NULL, NULL,NULL,NULL); 
     254INSERT INTO foltia_station VALUES (447, 'Yahoo!動画', -10, NULL, NULL, NULL, NULL, NULL, NULL,NULL,NULL); 
     255 
     256 
     257 
     258 
     259-- 
     260-- TOC entry 5 (OID 17163) 
     261-- Name: foltia_station_pkey; Type: CONSTRAINT; Schema: public; Owner: foltia 
     262-- 
     263 
     264-- ALTER TABLE ONLY foltia_station 
     265--     ADD CONSTRAINT foltia_station_pkey PRIMARY KEY (stationid); 
     266 
     267drop table foltia_envpolicy; 
     268CREATE TABLE foltia_envpolicy ( 
     269memberid integer  PRIMARY KEY, 
     270userclass integer, 
     271name text, 
     272passwd1 text , 
     273adddate timestamp, 
     274remotehost text 
     275); 
     276-- REVOKE ALL on "foltia_envpolicy" from PUBLIC; 
     277-- GRANT ALL on "foltia_envpolicy" to "foltia"; 
     278create  index foltia_envpolicy_index on foltia_envpolicy (name); 
     279insert into foltia_envpolicy  values ( '0','0','foltia','foltiapasswd',datetime('now'),''); 
  • foltia/install/perl/addatq.pl

    old new  
    1515 
    1616use DBI; 
    1717use DBD::Pg; 
     18use DBD::SQLite; 
    1819use Schedule::At; 
    1920use Time::Local; 
    2021 
    2122$path = $0; 
    2223$path =~ s/addatq.pl$//i; 
    23 if ($pwd ne "./"){ 
     24if ($path ne "./"){ 
    2425push( @INC, "$path"); 
    2526} 
    2627 
     
    3738} 
    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#件数数える 
    5352 
    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 
    6260        if($reservecounts[0] >= 1 ){#含まれていたら 
    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 ふくまれていたら 
    7371        }#endif 2つ以上     
    7472}elsif($titlecount[0]  == 1){ 
    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 
    8078#旧処理 
    8179# if ($titlecount[0]  == 1 ){ 
    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 
    8785sub addcue{ 
    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 , 
    121116$tid , 
     
    130125 
    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]; 
    138132} 
  • foltia/install/perl/addpidatq.pl

    old new  
    1313 
    1414use DBI; 
    1515use DBD::Pg; 
     16use DBD::SQLite; 
    1617use Schedule::At; 
    1718use Time::Local; 
    1819 
    1920$path = $0; 
    2021$path =~ s/addpidatq.pl$//i; 
    21 if ($pwd ne "./"){ 
     22if ($path ne "./"){ 
    2223push( @INC, "$path"); 
    2324} 
    2425 
     
    3536 
    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;; 
    41  
    42 $DBQuery =  "SELECT count(*) FROM  foltia_subtitle WHERE pid = '$pid' "; 
    43          $sth = $dbh->prepare($DBQuery); 
    44         $sth->execute(); 
     39$dbh = DBI->connect($DSN,$DBUser,$DBPass) ||die $DBI::error;; 
     40 
     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];#ビットレート取得 
    5450if ($titlecount[1] >= 1){ 
     
    5854} 
    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} 
    7468if ($stationl[1] => 1){ 
     
    8175}else{ 
    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 , 
    8982$stationid , 
  • foltia/install/perl/captureimagemaker.pl

    old new  
    1313 
    1414$path = $0; 
    1515$path =~ s/captureimagemaker.pl$//i; 
    16 if ($pwd ne "./"){ 
     16if ($path ne "./"){ 
    1717push( @INC, "$path"); 
    1818} 
    1919 
     
    5555$date = $filename[2]; 
    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"; 
    6161 
     
    6464$time = substr($time, 0, 4); 
    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"; 
    7070 
  • foltia/install/perl/changestbch.pl

    old new  
    2525 
    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} 
    3435require 'foltialib.pl'; 
     
    5354 
    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;; 
    59  
    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(); 
     57        $dbh = DBI->connect($DSN,$DBUser,$DBPass) ||die $DBI::error;; 
     58 
     59        $sth = $dbh->prepare($stmt{'changestbch.1'}); 
     60        $sth->execute($pid); 
    6361 @chstatus = $sth->fetchrow_array; 
    6462        $tunertype = $chstatus[0]; 
    6563        $tunercmd =  $chstatus[1]; 
  • foltia/install/perl/db/Pg.pl

    old new  
     1 
     2%main::stmt = ( 
     3'addatq.1' => "SELECT count(*) FROM foltia_tvrecord WHERE tid = ?", 
     4'addatq.2' => "SELECT count(*) FROM foltia_tvrecord WHERE tid = ? AND stationid = ?", 
     5'addatq.3' => "SELECT count(*) FROM foltia_tvrecord WHERE tid = ? AND stationid = '0'", 
     6'addatq.addcue.1' => "SELECT * FROM foltia_tvrecord WHERE tid = ?", 
     7'addatq.addcue.2' => "SELECT * FROM foltia_tvrecord WHERE tid = ? AND stationid = ?", 
     8'addatq.addcue.3' => "SELECT * from foltia_subtitle WHERE tid = ? AND startdatetime > ? AND startdatetime < ?", 
     9'addatq.addcue.4' => "SELECT stationid , stationrecch FROM foltia_station where stationid = ?", 
     10'addstq.addcue.5' => "SELECT * from foltia_subtitle WHERE tid = ? AND stationid = ? AND startdatetime > ? AND startdatetime < ?", 
     11'addatq.addcue.6' => "SELECT stationid , stationrecch FROM foltia_station where stationid = ?", 
     12 
     13'addpidatq.1' => "SELECT count(*) FROM foltia_subtitle WHERE pid = ?", 
     14'addpidatq.2' => "SELECT bitrate,digital FROM foltia_tvrecord , foltia_subtitle WHERE foltia_tvrecord.tid = foltia_subtitle.tid AND pid = ?", 
     15'addpidatq.3' => "SELECT stationrecch, digitalch, digitalstationband ,foltia_station.stationid FROM foltia_station,foltia_subtitle WHERE foltia_subtitle.pid = ? AND foltia_subtitle.stationid = foltia_station.stationid", 
     16'addpidatq.4' => "SELECT * FROM foltia_subtitle WHERE pid = ?", 
     17 
     18'changestbch.1' => "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 = ?", 
     19 
     20'envpolicyupdate.1' => "SELECT userclass,name,passwd1 FROM foltia_envpolicy", 
     21 
     22'foltialib.getstationid.1' => "SELECT count(*) FROM foltia_station WHERE stationname = ?", 
     23'foltialib.getstationid.2' => "SELECT stationid,stationname FROM foltia_station WHERE stationname = ?", 
     24'foltialib.getstationid.3' => "SELECT max(stationid) FROM foltia_station", 
     25'foltialib.getstationid.4' => "INSERT INTO foltia_station (stationid, stationname, stationrecch) VALUES (?, ?, ?)", 
     26'foltialib.getpidbympegfilename.1' => "SELECT pid FROM foltia_subtitle WHERE m2pfilename = ? LIMIT 1", 
     27'foltialib.changefilestatus.1' => "UPDATE foltia_subtitle SET filestatus = ?, lastupdate = now() WHERE pid = ?", 
     28'foltialib.getfilestatus.1' => "SELECT filestatus FROM foltia_subtitle WHERE pid = ?", 
     29 
     30'getxml2db.1' => "SELECT count(*) FROM foltia_program WHERE tid = ?", 
     31'getxml2db.2' => "INSERT into foltia_program VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?,  ?, ?)", 
     32'getxml2db.3' => "SELECT title FROM foltia_program WHERE tid = ?", 
     33'getxml2db.4' => "UPDATE foltia_program SET title = ? where tid = ?", 
     34'getxml2db.5' => "SELECT count(*) FROM foltia_subtitle WHERE tid = ? AND pid = ?", 
     35'getxml2db.6' => "UPDATE foltia_subtitle SET stationid = ?, countno = ?, subtitle = ?, startdatetime = ?, enddatetime = ?, startoffset = ?, lengthmin = ? WHERE tid = ? AND pid = ?", 
     36'getxml2db.7' => "UPDATE foltia_subtitle SET stationid = ?, countno = ?, subtitle = ?, startdatetime = ?, enddatetime = ?, startoffset = ?, lengthmin = ? WHERE tid = ? AND pid = ?", 
     37'getxml2db.8' => "INSERT into foltia_subtitle (pid, tid, stationid, countno, subtitle, startdatetime, enddatetime, startoffset, lengthmin) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)", 
     38'getxml2db.9' => "INSERT into foltia_subtitle (pid, tid, stationid, countno, subtitle, startdatetime, enddatetime, startoffset, lengthmin) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)", 
     39 
     40'ipodtranscode.1' => "SELECT foltia_subtitle.pid,foltia_subtitle.tid,foltia_subtitle.m2pfilename,filestatus,foltia_program.aspect,foltia_subtitle.countno FROM foltia_subtitle, foltia_program, foltia_m2pfiles WHERE filestatus >= ? AND filestatus < ? AND foltia_program.tid = foltia_subtitle.TID AND foltia_program.PSP = 1 AND foltia_m2pfiles.m2pfilename = foltia_subtitle.m2pfilename ORDER BY enddatetime ASC LIMIT 1", 
     41'ipodtranscode.2' => "SELECT title, countno, subtitle FROM foltia_program, foltia_subtitle WHERE foltia_program.tid = foltia_subtitle.tid AND foltia_subtitle.pid = ?", 
     42'ipodtranscode.updatemp4file.1' => "UPDATE foltia_subtitle SET PSPfilename = ? WHERE pid = ?", 
     43'ipodtranscode.updatemp4file.2' => "INSERT INTO foltia_mp4files VALUES (?, ?)", 
     44 
     45'ipodtranscode.counttranscodefiles.1' => "SELECT count(*) FROM foltia_subtitle, foltia_program, foltia_m2pfiles WHERE filestatus >= ? AND filestatus < ? AND foltia_program.tid = foltia_subtitle.TID AND foltia_program.PSP = 1 AND foltia_m2pfiles.m2pfilename = foltia_subtitle.m2pfilename", 
     46 
     47'mklocalizeddir.1' => "SELECT title FROM foltia_program where tid = ?", 
     48 
     49'recwrap.1' => "UPDATE foltia_subtitle SET m2pfilename = ? WHERE pid = ?", 
     50'recwrap.2' => "INSERT into foltia_m2pfiles VALUES (?)", 
     51'recwrap.3' => "SELECT psp,aspect,title FROM foltia_program WHERE tid = ?", 
     52'recwrap.4' => "SELECT subtitle FROM foltia_subtitle WHERE tid = ? AND countno = ?", 
     53'recwrap.5' => "UPDATE foltia_subtitle SET PSPfilename = ? WHERE pid = ?", 
     54'recwrap.6' => "INSERT into foltia_mp4files VALUES (?, ?)", 
     55'recwrap.7' => "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 FROM foltia_subtitle ,foltia_tvrecord WHERE foltia_tvrecord.tid = foltia_subtitle.tid AND foltia_tvrecord.tid = ? AND foltia_subtitle.startdatetime = ? AND foltia_tvrecord.digital = 1", 
     56 
     57'schedulecheck.1' => "SELECT count(*) FROM foltia_tvrecord", 
     58'schedulecheck.2' => "SELECT tid ,stationid FROM foltia_tvrecord", 
     59 
     60'singletranscode.1' => "SELECT pid FROM foltia_subtitle WHERE m2pfilename = ?", 
     61'singletranscode.2' => "SELECT count(*) FROM foltia_subtitle WHERE tid = ? AND countno = ?", 
     62'singletranscode.3' => "SELECT count(*) FROM foltia_subtitle WHERE tid = ?", 
     63'singletranscode.4' => "SELECT psp,aspect,title FROM foltia_program WHERE tid = ?", 
     64'singletranscode.5' => "SELECT subtitle FROM foltia_subtitle WHERE tid = ? AND countno = ?", 
     65'singletranscode.6' => "UPDATE foltia_subtitle SET PSPfilename = ? WHERE pid = ?", 
     66'singletranscode.7' => "INSERT into foltia_mp4files values (?, ?)", 
     67 
     68'updatem2pfiletable.1' => "DELETE FROM foltia_m2pfiles", 
     69'updatem2pfiletable.2' => "INSERT into foltia_m2pfiles values (?)", 
     70'updatem2pfiletable.3' => "DELETE FROM foltia_mp4files", 
     71'updatem2pfiletable.4' => "INSERT into foltia_mp4files values (?, ?)", 
     72 
     73'xmltv2foltia.chkerase.1' => "DELETE FROM foltia_epg WHERE startdatetime > ? AND ontvchannel = ?", 
     74'xmltv2foltia.registdb.1' => "SELECT max(epgid) FROM foltia_epg", 
     75'xmltv2foltia.registdb.2' => "INSERT INTO foltia_epg VALUES (?, ?, ?, ?, ?, ?, ?, ?)", 
     76 
     77); 
     78 
     791; 
  • foltia/install/perl/db/SQLite.pl

    old new  
     1 
     2require 'db/Pg.pl'; 
     3 
     4$stmt{'foltialib.changefilestatus.1'} = "UPDATE foltia_subtitle SET filestatus = ?, lastupdate = datetime('now', 'localtime') WHERE pid = ?"; 
     5 
     61; 
  • foltia/install/perl/deletemovie.pl

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

    old new  
    2424 
    2525$path = $0; 
    2626$path =~ s/digitaltvrecording.pl$//i; 
    27 if ($pwd ne "./"){ 
     27if ($path ne "./"){ 
    2828push( @INC, "$path"); 
    2929} 
    3030 
     
    111111                $outputfile = $outputpath.$outputfile ; 
    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"; 
    117117                $outputfilewithoutpath = $outputfile ; 
  • foltia/install/perl/envpolicyupdate.pl

    old new  
    1515 
    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} 
    2425 
     
    3233$returnparam = getphpstyleconfig("environmentpolicytoken"); 
    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 
    4441#なければつくる 
  • foltia/install/perl/folprep.pl

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

    old new  
    2727$phptoolpath = $toolpath ;#php版の初期設定の位置。デフォルトではperlと同じ位置 
    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=""; 
    3641 
  • foltia/install/perl/foltialib.pl

    old new  
    33 
    44$path = $0; 
    55$path =~ s/foltialib.pl$//i; 
    6 if ($pwd ne "./"){ 
     6if ($path ne "./"){ 
    77push( @INC, "$path"); 
    88} 
    99require "foltia_conf1.pl"; 
     
    1212#  foltia lib 
    1313use DBI; 
    1414use DBD::Pg; 
     15use DBD::SQLite; 
     16use POSIX qw(strftime); 
    1517 
    16  
    17          $DBDriv=$main::DBDriv; 
    18          $DBHost=$main::DBHost; 
    19          $DBPort=$main::DBPort; 
    20          $DBName=$main::DBName; 
     18$DSN=$main::DSN; 
    2119         $DBUser=$main::DBUser; 
    2220         $DBPass=""; 
    2321         
     
    4644#------------------------------ 
    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){ 
    5250        open (DEBUGLOG , ">>$toolpath/debuglog.txt") || die "Cant write log file.$! \n "; 
     
    145143#戻り値: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; 
    155152 
    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 
    163159$stationid  = $stationinfo[0]; 
     
    165161 
    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; 
    172167my $stationid = $stationinfo[0] ; 
    173168$stationid  ++; 
    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 
    184177#print "Error  getstationid $stationcount[0] stations found. $DBQuery\n"; 
     
    286279        return  0 ; 
    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]; 
    296288 
     
    311303} 
    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{ 
    320311        &writelog("foltialib changefilestatus ERR Sttus invalid:$updatestatus"); 
     
    350341        return  0 ; 
    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; 
    359349my $status  = $statusinfo[0]; 
  • foltia/install/perl/getxml2db.pl

    old new  
    1818use Time::Local; 
    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} 
    2829require "foltialib.pl"; 
     
    4748        #$uri="http://syobocal.orz.hm/cal_chk.xml"; 
    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  
    5956my  $CacheDir = '/tmp/shobocal'; 
     
    104101$programtitlename =~ s/\&lt\;/</gi; 
    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'); 
    110108Jcode::convert(\$item{SubTitle},'euc'); 
     
    114112$programSubTitle =~ s/\&lt\;/</gi; 
    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; 
    120118$edtime = &syobocaldate2foltiadate($item{EdTime}); 
     
    126124$stationid = &getstationid($item{ChName}); 
    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  
    134131 if ($titlecount[0] == 0){ 
     
    136133 
    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"); 
    144  
    145136 
     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 
    162153}# end if TID 
    163154 
    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){ 
    171161        #PIDあったら上書き更新 
     
    173163#       DBD::Pg::st execute failed: ERROR:  invalid input syntax for type bigint: "" at /home/foltia/perl/getxml2db.pl line 147. 
    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        #なければ追加 
    205174         
    206175        #こっちに入る時刻はオフセットされた時刻! 
    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} 
    218185 
    219  
    220186#print "$DBQuery\n\n\n"; 
    221187#debug 20050803 
    222188#&writelog("getxml2db $DBQuery"); 
     
    225190}#if 
    226191}#foreach 
    227192 
    228 #$oserr = $dbh->commit; 
     193$oserr = $dbh->commit; 
    229194##      $dbh->disconnect(); 
    230  
    231  
  • foltia/install/perl/ipodtranscode.pl

    old new  
    1212 
    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} 
    2223require "foltialib.pl"; 
     
    3435} 
    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# タイトル取得 
    4241#トラコンフラグがたっていてステータス50以上150未満のファイルを古い順にひとつ探す 
     
    5655sleep 30; 
    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"; 
    7062&writelog("ipodtranscode DEBUG $DBQuery"); 
     
    8577# 実際のトラコン 
    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; 
    9784$programtitle[2] =~ s/\"/\\"/gi; 
     
    388375&writelog("ipodtranscode DEBUG mplayer -ss 00:01:20 -vo jpeg:outdir=$pspdirname -ao null -sstep 1 -frames 3  -v 3 $outputfilename"); 
    389376 
    390377if (-e "$pspdirname/$thmfilename"){ 
    391 $timestamp =`date "+%Y%m%d-%H%M%S"`
     378       $timestamp = strftime("%Y%m%d-%H%M%S", localtime)
    392379chomp $timestamp; 
    393380        system("convert -crop 160x120+1+3 -resize 165x126\! $pspdirname/00000002.jpg $pspdirname/$thmfilename".$timestamp.".THM"); 
    394381}else{ 
     
    406393 
    407394if (-e "${mp4outdir}MAQ${mp4filenamestring}.MP4"){ 
    408395# 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"); 
     396        $sth = $dbh->prepare($stmt{'ipodtranscode.updatemp4file.1'}); 
     397        $sth->execute($mp4filename, $pid); 
     398        &writelog("ipodtranscode UPDATEsubtitleDB $stmt{'ipodtranscode.updatemp4file.1'}"); 
    413399 
    414400# 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"); 
     401        $sth = $dbh->prepare($stmt{'ipodtranscode.updatemp4file.2'}); 
     402        $sth->execute($tid, $mp4filename); 
     403        &writelog("ipodtranscode UPDATEmp4DB $stmt{'ipodtranscode.updatemp4file.2'}"); 
    419404 
    420405&changefilestatus($pid,$FILESTATUSALLCOMPLETE); 
    421406}else{ 
     
    426411}#updatemp4file 
    427412 
    428413sub 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(); 
     414    $sth = $dbh->prepare($stmt{'ipodtranscode.counttranscodefiles.1'}); 
     415    $sth->execute($FILESTATUSRECEND, $FILESTATUSTRANSCODECOMPLETE); 
    433416my @titlecount= $sth->fetchrow_array; 
    434417 
    435418return ($titlecount[0]); 
  • foltia/install/perl/mklocalizeddir.pl

    old new  
    1515use Jcode; 
    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} 
    2525require "foltialib.pl"; 
     
    4242#.localized用文字列取得 
    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] ; 
    5552$titleeuc = $title ; 
  • foltia/install/perl/recwrap.pl

    old new  
    1414 
    1515use DBI; 
    1616use DBD::Pg; 
     17use DBD::SQLite; 
    1718use Schedule::At; 
    1819use Time::Local; 
    1920use Jcode; 
    2021 
    2122$path = $0; 
    2223$path =~ s/recwrap.pl$//i; 
    23 if ($pwd ne "./"){ 
     24if ($path ne "./"){ 
    2425push( @INC, "$path"); 
    2526} 
    2627 
     
    4546$digitalch= $ARGV[9] ; 
    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 
    5352if ($usedigital == 1){ 
     
    5655        $extension = ".m2p";#MPEG2の拡張子 
    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 
    6261if ($tid == 0){ 
     
    7675#デジタルなら 
    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; 
    8281 
     
    118117 
    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"); 
    124123$oserr = $oserr / 256; 
     
    130129}#endif #デジタル優先フラグ 
    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){ 
    138137                                &writelog("recwrap WARNING  Giving up recording."); 
     
    140139                        } 
    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){ 
    151150                                &writelog("recwrap ABORT recfile exist. in resume process.[$outputfilename] $recch $reclength 0 0 $bitrate $tid $countno $pid"); 
     
    159158 
    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向けキャプチャ画像作成 
    175172if (-e "$toolpath/perl/captureimagemaker.pl"){ 
     
    183180 
    184181# MPEG4 ------------------------------------------------------ 
    185182#MPEG4トラコン必要かどうか 
    186 $DBQuery =  "SELECT psp,aspect,title FROM foltia_program WHERE tid = '$tid' "; 
    187          $sth = $dbh->prepare($DBQuery); 
    188         $sth->execute(); 
     183$sth = $dbh->prepare($stmt{'recwrap.3'}); 
     184$sth->execute($tid); 
    189185 @psptrcn= $sth->fetchrow_array; 
    190186if ($psptrcn[0]  == 1 ){#トラコン番組 
    191187&writelog("recwrap Launch ipodtranscode.pl"); 
     
    299295#タイムスタンプが最新のMP4ファイル名取得 
    300296my $newestmp4filename = `cd $pspdirname ; ls -t *.MP4 | head -1`; 
    301297 if ($newestmp4filename =~ /M4V$tid/){ 
    302         $nowcountno = $' ; 
     298               $nowcountno = $' ;#' 
    303299                $nowcountno++; 
    304300                $pspfilnameft = sprintf("%02d",$nowcountno); 
    305301        while (-e "$pspdirname/M4V".$pspfilnamehd.$pspfilnameft.".MP4"){ 
     
    347343                        } 
    348344                        &writelog("recwrap TRCN WAITING :$trcnprocesses / $cpucores :$outputfilename $loadaverage"); 
    349345                sleep 113; 
    350                sleep ($recch)*5; 
     346            sleep ($recch); //*5; 
    351347        } 
    352348} until ($trcnprocesses  < $cpucores); 
    353349 
     
    357353        system("$toolpath/perl/transcode/vfr4psp.sh $recfolderpath/$outputfilename $pspfilname $pspdirname $psptrcn[1]"); 
    358354        &writelog("recwrap TRCNEND  vfr4psp.sh $recfolderpath/$outputfilename $pspfilname $pspdirname $psptrcn[1]"); 
    359355        #最適化 
    360         $DBQuery =  "SELECT subtitle  FROM  foltia_subtitle WHERE tid = '$tid' AND countno = '$countno' "; 
    361                  $sth = $dbh->prepare($DBQuery); 
    362                 $sth->execute(); 
     356        $sth = $dbh->prepare($stmt{'recwrap.4'}); 
     357        $sth->execute($tid, $countno); 
    363358         @programtitle = $sth->fetchrow_array; 
    364359        if ( $countno == "0" ){ 
    365360                $pspcountno = ""; 
     
    395390&writelog("recwrap THAMI  convert -crop 160x120+1+3 -resize 165x126\! $pspdirname/00000002.jpg $pspdirname/M4V$pspdirname.THM "); 
    396391 
    397392if (-e "$pspdirname/$thmfilename"){ 
    398 $timestamp =`date "+%Y%m%d-%H%M%S"`
     393       $timestamp = strftime("%Y%m%d-%H%M%S", localtime)
    399394chomp $timestamp; 
    400395        system("convert -crop 160x120+1+3 -resize 165x126\! $pspdirname/00000002.jpg $pspdirname/$thmfilename".$timestamp.".THM"); 
    401396 
     
    411406 
    412407 
    413408# 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"); 
     409    $sth = $dbh->prepare($stmt{'recwrap.5'}); 
     410    $sth->execute($mp4filename, $pid); 
     411    &writelog("recwrap UPDATEsubtitleDB $stmt{'recwrap.5'}"); 
    418412 
    419413# 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"); 
     414    $sth = $dbh->prepare($stmt{'recwrap.6'}); 
     415    $sth->execute($tid, $mp4filename); 
     416    &writelog("recwrap UPDATEmp4DB $stmt{'recwrap.6'}"); 
    424417 
    425418&changefilestatus($pid,200); 
    426419}#PSPトラコンあり 
    427420 
    428421sub continuousrecordingcheck(){ 
    429 my $now = `date  +%s --date "2 min "`
     422    my $now = time() + 60 * 2
    430423&writelog("recwrap DEBUG continuousrecordingcheck() now $now"); 
    431424my @processes =`ps ax | grep recfriio`; 
    432425 
     
    473466                @filenameparts = split(/\./,$starttime); 
    474467                $startdatetime = $startdate.$filenameparts[0]; 
    475468                #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); 
     469                    &writelog("recwrap DEBUG continuousrecordingcheck() $stmt{'recwrap.7'}"); 
     470                    $sth = $dbh->prepare($stmt{'recwrap.7'}); 
    486471        &writelog("recwrap DEBUG continuousrecordingcheck() prepare"); 
    487         $sth->execute(); 
     472                   $sth->execute($tid, $startdatetime); 
    488473        &writelog("recwrap DEBUG continuousrecordingcheck() execute"); 
    489474        @recfile = $sth->fetchrow_array; 
    490475        &writelog("recwrap DEBUG continuousrecordingcheck() @recfile  $recfile[0] $recfile[1] $recfile[2] $recfile[3] $recfile[4] $recfile[5] $recfile[6] $recfile[7] $recfile[8] $recfile[9] "); 
  • foltia/install/perl/schedulecheck.pl

    old new  
    1313 
    1414use DBI; 
    1515use DBD::Pg; 
     16use DBD::SQLite; 
    1617use Schedule::At; 
    1718use Time::Local; 
    1819 
    1920$path = $0; 
    2021$path =~ s/schedulecheck.pl$//i; 
    21 if ($pwd ne "./"){ 
     22if ($path ne "./"){ 
    2223push( @INC, "$path"); 
    2324} 
    2425 
     
    2829system("$toolpath/perl/getxml2db.pl"); 
    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; 
    4642 
    4743 if ($titlecount[0]  == 0 ){ 
    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()) { 
    5549#キュー再投入 
  • foltia/install/perl/singletranscode.pl

    old new  
    2727 
    2828use DBI; 
    2929use DBD::Pg; 
     30use DBD::SQLite; 
    3031use Schedule::At; 
    3132use Time::Local; 
    3233use Jcode; 
    3334 
    3435$path = $0; 
    3536$path =~ s/singletranscode.pl$//i; 
    36 if ($pwd ne "./"){ 
     37if ($path ne "./"){ 
    3738push( @INC, "$path"); 
    3839} 
    3940 
     
    6263# -- recwrapからほとんどコピー 
    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]  == "" ){ 
    7875                $pid = $pidarray[0] 
     
    8582 
    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 
    9994 unless ($subticount[0]  >= 1){ 
     
    119114 
    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 ){#トラコン番組 
    127121 
     
    226219#タイムスタンプが最新のMP4ファイル名取得 
    227220my $newestmp4filename = `cd $pspdirname ; ls -t *.MP4 | head -1`; 
    228221 if ($newestmp4filename =~ /M4V$tid/){ 
    229         $nowcountno = $' ; 
     222               $nowcountno = $' ;#' 
    230223                $nowcountno++; 
    231224                $pspfilnameft = sprintf("%02d",$nowcountno); 
    232225        while (-e "$pspdirname/M4V".$pspfilnamehd.$pspfilnameft.".MP4"){ 
     
    260253 
    261254#最適化 
    262255 
    263 $DBQuery =  "SELECT subtitle  FROM  foltia_subtitle WHERE tid = '$tid' AND countno = '$countno' "; 
    264          $sth = $dbh->prepare($DBQuery); 
    265         $sth->execute(); 
     256    $sth = $dbh->prepare($stmt{'singletranscode.5'}); 
     257    $sth->execute($tid, $countno); 
    266258 @programtitle = $sth->fetchrow_array; 
    267259 
    268260if ( $countno == "0" ){ 
     
    284276&writelog("singletranscode THAMI  convert -crop 160x120+1+3 -resize 165x126\! $pspdirname/00000002.jpg $pspdirname/M4V$pspdirname.THM "); 
    285277 
    286278if (-e "$pspdirname/M4V".$pspfilname.".THM"){ 
    287 $timestamp =`date "+%Y%m%d-%H%M%S"`
     279       $timestamp = strftime("%Y%m%d-%H%M%S", localtime)
    288280chomp $timestamp; 
    289281        system("convert -crop 160x120+1+3 -resize 165x126\! $pspdirname/00000002.jpg $pspdirname/M4V".$pspfilname.".THM.".$timestamp.".THM"); 
    290282 
     
    296288# rm -rf 00000002.jpg   
    297289system("rm -rf $pspdirname/0000000*.jpg "); 
    298290 
    299  
    300  
    301  
    302291# MP4ファイル名をPIDレコードに書き込み 
    303292unless ($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"); 
     293        $sth = $dbh->prepare($stmt{'singletranscode.6'}); 
     294        $sth->execute("M4V$pspfilname.MP4", $pid); 
     295        &writelog("singletranscode UPDATEsubtitleDB $stmt{'singletranscode.6'}"); 
    311296}else{ 
    312297&writelog("singletranscode PID not found"); 
    313298} 
    314299# 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"); 
     300    $sth = $dbh->prepare($stmt{'singletranscode.7'}); 
     301    $sth->execute($tid, "M4V$pspfilname.MP4"); 
     302    &writelog("singletranscode UPDATEmp4DB $stmt{'singletranscode.7'}"); 
    319303 
    320304}#PSPトラコンあり 
    321  
    322  
  • foltia/install/perl/tvrecording.pl

    old new  
    2828 
    2929$path = $0; 
    3030$path =~ s/tvrecording.pl$//i; 
    31 if ($pwd ne "./"){ 
     31if ($path ne "./"){ 
    3232push( @INC, "$path"); 
    3333} 
    3434 
     
    300300#               if ($ARGV[3] =~ /[0-9]{8}-[0-9]{4}/){ 
    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]; 
    306306                $outputfile = &filenameinjectioncheck($outputfile); 
    307307                $outputfilewithoutpath = $outputfile ; 
    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"; 
    316316                $outputfilewithoutpath = $outputfile ; 
  • foltia/install/perl/updatem2pfiletable.pl

    old new  
    1515 
    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 
    4240$oserr = $dbh->commit; 
     
    4543@mp4filelist = `find ${recfolderpath}/ | grep MP4`;#by foltia dev ticket #5 http://www.dcc-jpl.com/foltia/ticket/5 
    4644 
    4745# ひとまず消す 
    48 $query =  "DELETE  FROM  foltia_mp4files  "; 
    49          $sth = $dbh->prepare($query); 
     46$sth = $dbh->prepare($stmt{'updatem2pfiletable.3'}); 
    5047        $sth->execute(); 
    5148 
    5249 
     
    5754$filetid = $fileline[0]; 
    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 
    6461}#end if 
  • foltia/install/perl/xmltv2foltia.pl

    old new  
    2929use Time::Local; 
    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} 
    3839require "foltialib.pl"; 
    3940 
    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(<>){ 
    5151#print $_; 
     
    186186 
    187187}elsif(/<\/programme>/){ 
    188188#登録処理はココで 
    189 #&writelog("xmltv2foltia DEBUG call chkerase $item{start},$item{channel}"); 
     189#&writelog("xmltv2foltia DEBUG call chkerase $item{'start'},$item{'channel'}"); 
    190190 
    191 &chkerase($item{start},$item{channel}); 
    192 if ($item{subtitle} ne "" ){ 
    193         $registdesc = $item{subtitle}." ".$item{desc}; 
     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} 
    200200#$item{stop} 
     
    215215}# endif 
    216216}# while 
    217217 
     218$dbh->commit; 
     219 
     220#end 
     221################ 
     222 
    218223sub chkerase{ 
    219224# xmltvからきた日付とチャンネルをfoltia epgと比較 
    220225my $foltiastarttime = $_[0]; # 14桁 
     
    231236my $epgstartdatetime = $today * 10000 ; # 200508070000 12桁 
    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 ; 
    240244}else{ 
     
    260265 
    261266if($foltiastarttime > $todaytime){ 
    262267         
    263         my $DBQuery =  "SELECT max(epgid) FROM foltia_epg "; 
    264                  $sth = $dbh->prepare($DBQuery); 
     268        $sth = $dbh->prepare($stmt{'xmltv2foltia.registdb.1'}); 
    265269                $sth->execute(); 
    266270         @currentepgid = $sth->fetchrow_array; 
    267271          
     
    273277        } 
    274278#&writelog("xmltv2foltia DEBUG $currentepgid[0] /  $newepgid"); 
    275279my $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  
     280#       $newepgid = $dbh->quote($newepgid ); 
     281#       $foltiastarttime = $dbh->quote($foltiastarttime); 
     282#       $foltiaendtime = $dbh->quote($foltiaendtime ); 
     283#       $lengthmin = $dbh->quote($lengthmin ); 
     284#       $channel = $dbh->quote($channel ); 
     285#       $title = $dbh->quote($title); 
     286#       $desc = $dbh->quote($desc); 
     287#       $category = $dbh->quote($category); 
     288 
     289        $sth = $dbh->prepare($stmt{'xmltv2foltia.registdb.2'}); 
     290        $sth->execute($newepgid, $foltiastarttime, $foltiaendtime, $lengthmin, $channel, $title, $desc, $category) || 
     291            warn "error: $newepgid, $foltiastarttime, $foltiaendtime, $lengthmin, $channel, $title, $desc, $category\n"; 
    290292 
    291293# &writelog("xmltv2foltia DEBUG $DBQuery"); 
    292294 
  • foltia/install/php/accountregist.php

    old new  
    5757//すでにそのユーザが存在しているかどうか確認 
    5858if ($username != ""){ 
    5959$query = " 
    60 SELECT memberid ,userclass,name,passwd1  
     60SELECT count(memberid) 
    6161FROM foltia_envpolicy  
    6262WHERE foltia_envpolicy.name  = '$username'   
    6363"; 
    6464        $isaccountexist = m_query($con, $query, "DBクエリに失敗しました"); 
    65         $isaccountexistncount = pg_num_rows($isaccountexist); 
     65        $isaccountexistncount = $isaccountexist->fetchColumn(0); 
    6666 
    6767        if ($isaccountexistncount == 0){ 
    6868        //valid 
     
    8484FROM  foltia_envpolicy  
    8585"; 
    8686        $rs = m_query($con, $query, "DBクエリに失敗しました"); 
    87         $maxrows = pg_num_rows($rs); 
    88         if ($maxrows == 0)
    89         $nextcno = 1
     87        $maxid = $rs->fetchColumn(0); 
     88        if ($maxid)
     89               $nextcno = $maxid + 1
    9090        }else{ 
    91         $rowdata = pg_fetch_row($rs, 0); 
    92         $nextcno = $rowdata[0]; 
    93         $nextcno++ ; 
     91                $nextcno = 1; 
    9492        } 
    9593 
    9694//登録 
  • foltia/install/php/delepgp.php

    old new  
    7373 "; 
    7474 
    7575        $rs = m_query($con, $query, "DBクエリに失敗しました"); 
    76         $maxrows = pg_num_rows($rs); 
    77                          
    78                 if ($maxrows == 0) { 
     76$rowdata = $rs->fetch(); 
     77if (! $rowdate) { 
    7978                die_exit("登録番組がありません<BR>"); 
    8079                } 
    81                 $rowdata = pg_fetch_row($rs, 0); 
    8280 
    8381                $pid = htmlspecialchars($rowdata[0]); 
    8482                $stationid = htmlspecialchars($rowdata[1]); 
  • foltia/install/php/deletemovie.php

    old new  
    9086 AND foltia_subtitle.tid = $filesplit[0]  
    9187"; 
    9288$rs = m_query($con, $query, "DBクエリに失敗しました"); 
    93 $rowdata = pg_fetch_row($rs, $row); 
     89                                $rall = $rs->fetchAll(); 
     90                                $rowdata = $rall[$row]; 
    9491//print" $fName./$rowdata[1]//$rowdata[2]<BR>\n"; 
    9592$title = $rowdata[1]; 
    9693$subtitle = ""; 
     
    106102 AND foltia_subtitle.countno = $filesplit[1]  
    107103"; 
    108104$rs = m_query($con, $query, "DBクエリに失敗しました"); 
    109 $rowdata = pg_fetch_row($rs, $row); 
     105                                $rall = $rs->fetchAll(); 
     106                                $rowdata = $rall[$row]; 
    110107//print" $fName./$rowdata[1]/$rowdata[2]/$rowdata[3]<BR>\n"; 
    111108$title = $rowdata[1]; 
    112109$count = $rowdata[2]; 
  • foltia/install/php/delreserve.php

    old new  
    4343 
    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>"); 
    5453                } 
     
    7271WHERE foltia_tvrecord.tid = foltia_program.tid  AND foltia_tvrecord.stationid = foltia_station .stationid  AND foltia_tvrecord.tid = $tid AND foltia_tvrecord.stationid = $sid  "; 
    7372 
    7473        $rs = m_query($con, $query, "DBクエリに失敗しました"); 
    75         $maxrows = pg_num_rows($rs); 
    76                          
    77                 if ($maxrows == 0) { 
     74$rowdata = $rs->fetch(); 
     75if (! $rowdate) { 
    7876                die_exit("登録番組がありません<BR>"); 
    7977                } 
    80                 $rowdata = pg_fetch_row($rs, 0); 
    8178 
    8279                $tid = htmlspecialchars($rowdata[0]); 
    8380                $stationname = htmlspecialchars($rowdata[1]); 
     
    167164ORDER BY foltia_subtitle.startdatetime  ASC 
    168165"; 
    169166        $rs = m_query($con, $query, "DBクエリに失敗しました"); 
    170         $maxrows = pg_num_rows($rs); 
    171                          
    172                 if ($maxrows == 0) { 
     167$rowdata = $rs->fetch(); 
     168if (! $rowdata) { 
    173169                echo("放映予定はありません<BR>"); 
    174                 } 
    175                 else{ 
    176                 $maxcols = pg_num_fields($rs);           
     170}else{ 
     171        $maxcols = $rs->columnCount(); 
    177172?> 
    178173  <table BORDER="0" CELLPADDING="0" CELLSPACING="2" WIDTH="100%" BGCOLOR="#bcf1be"> 
    179174        <thead> 
     
    191186        <tbody> 
    192187                <?php 
    193188                        /* テーブルのデータを出力 */ 
    194                        for ($row = 0; $row < $maxrows; $row++) { /* 行に対応 */ 
     189             do { 
    195190                                echo("<tr>\n"); 
    196                                 /* pg_fetch_row で一行取り出す */ 
    197                                 $rowdata = pg_fetch_row($rs, $row); 
    198  
    199191                                for ($col = 0; $col < $maxcols; $col++) { /* 列に対応 */ 
    200192                                        echo("<td>".htmlspecialchars($rowdata[$col])."<br></td>\n"); 
    201193                                } 
    202194                                echo("</tr>\n"); 
    203                        } 
     195             } while ($row = $rs->fetch()); 
    204196                }//end if 
    205197                ?> 
    206198        </tbody> 
  • foltia/install/php/folcast.php

    old new  
    5050 
    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  
    5656        "; 
     
    6161WHERE foltia_program.tid = $tid    
    6262"; 
    6363        $titlers = m_query($con, $query, "DBクエリに失敗しました"); 
    64         $rowdata = pg_fetch_row($titlers, 0);  
     64        $rowdata = $titlers->fetch(); 
    6565        $rsstitle = $rowdata[1]; 
    6666}else{ 
    6767 
    6868$query = " 
    6969SELECT  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  
     70foltia_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  
    7171offset 0 limit  $max  
    7272        "; 
    7373        $rsstitle = "新規録画"; 
     
    9696print $header; 
    9797 
    9898        $rs = m_query($con, $query, "DBクエリに失敗しました"); 
    99        $maxrows = pg_num_rows($rs); 
     99$rowdata = $rs->fetch(); 
    100100 
    101 if ($maxrows == 0) { 
     101if (! $rowdata) { 
    102102                                //die_exit("No items");  
    103103}else{ 
    104  
    105 for ($row = 0; $row < $maxrows; $row++) {  
    106                 $rowdata = pg_fetch_row($rs, $row); 
    107                  
     104        do { 
    108105//$title = mb_convert_encoding($rowdata[1],"UTF-8", "EUC-JP"); 
    109106$tid =  $rowdata[0]; 
    110107$title = $rowdata[1]; 
     
    162159$item = mb_convert_encoding($item,"UTF-8", "EUC-JP"); 
    163160print $item ; 
    164161 
    165 }//for 
     162        } while ($rowdata = $rs->fetch()); //do 
    166163 
    167164}//if 
    168165                ?> 
  • foltia/install/php/foltia_config2.php.template

    old new  
    2626                $usedigital = 1;//Friioなどでデジタル録画をするか 1:する 0:しない 
    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アドレス 
    3533 
  • foltia/install/php/foltialib.php

    old new  
    9494        } 
    9595         
    9696        /* LIKE 用の文字列のエスケープ */ 
     97/* unused 
    9798        function escape_like($sql, $quote = TRUE) { 
    9899                return ($quote ? "'" : "") . 
    99100                       str_replace(array("\\\\",     "%"    , "_"    ), 
     
    101102                                   pg_escape_string($sql)) . 
    102103                       ($quote ? "'" : ""); 
    103104        } 
     105*/ 
    104106         
    105107        /* SQL 文字列のエスケープ */ 
    106108        function escape_string($sql, $quote = FALSE) { 
     
    109111                } 
    110112                return ($quote ? "'" : "") . 
    111113                       pg_escape_string($sql) . 
     114            //sqlite_escape_string($sql) . 
    112115                       ($quote ? "'" : ""); 
    113116        } 
    114117         
     
    125128         
    126129        /* PostgreSQL サーバに接続 */ 
    127130        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("データベースに接続出来ませんでした。"); 
     131        try { 
     132                $dbh = new PDO(DSN); 
     133                $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); 
     134                return($dbh); 
     135        } catch (PDOException $e) { 
     136                die_exit($e->getMessage() . ": データベースに接続出来ませんでした。"); 
    139137                } 
    140138                /* データベースと、PHP の内部文字コードが違う場合 */ 
    141                 return($con); 
    142139        } 
    143140 
    144141        /* データベースとの接続を切り離す */ 
    145        function m_close($con) { 
    146                return @pg_close($con)
     142function m_close($dbh) { 
     143        return null
    147144        } 
    148145 
    149146        /* SQL 文を実行 */ 
    150         function m_query($con, $query, $errmessage) { 
    151                 $rtn = @pg_query($con, $query); 
    152                 if (!$rtn) { 
     147function m_query($dbh, $query, $errmessage) { 
     148        try { 
     149                $rtn = $dbh->query($query); 
     150                return($rtn); 
     151        } catch (PDOException $e) { 
    153152                        /* エラーメッセージに SQL 文を出すのはセキュリティ上良くない!! */ 
    154153                        $msg = $errmessage . "<br>\n" . 
    155                                @pg_last_error($con) . "<br>\n" . 
     154                    $e->getMessage() . "<br>\n" . 
     155                    var_export($e->errorInfo, true) . "<br>\n" . 
    156156                               "<small><code>" . htmlspecialchars($query) . 
    157157                               "</code></small>\n"; 
    158                                $rtn = @pg_query($con, "rollback");//04.4.8 
    159                        m_close($con)
     158//              $dbh->rollBack(); 
     159                $dbh = null
    160160                        die_exit($msg); 
    161161                } 
    162                 return($rtn); 
    163162        } 
    164163 
    165164        /* select した結果をテーブルで表示 */ 
    166165        function m_showtable($rs) { 
    167166                /* 検索件数 */ 
    168                $maxrows = pg_num_rows($rs)
     167        $maxrows = 0
    169168                 
    170                 if ($maxrows == 0) { 
     169        $rowdata = $rs->fetch(); 
     170        if (! $rowdata) { 
    171171                        echo("<p class=\"msg\">データが存在しません</p>\n"); 
    172172                        return 0; 
    173173                } 
    174174                 
    175175                /* フィールド数 */ 
    176                $maxcols = pg_num_fields($rs); 
     176        $maxcols = $rs->columnCount(); 
    177177                ?> 
    178178<table class="list" summary="データ検索結果を表示" border="1"> 
    179179        <thead> 
     
    182182                                /* テーブルのヘッダーを出力 */ 
    183183                                for ($col = 1; $col < $maxcols; $col++) { 
    184184                                        /* pg_field_name() はフィールド名を返す */ 
    185                                         $f_name = htmlspecialchars(pg_field_name($rs, $col)); 
     185                     $meta = $rs->getColumnMeta($col); 
     186                     $f_name = htmlspecialchars($meta["name"]); 
    186187                                        echo("<th abbr=\"$f_name\">$f_name</th>\n"); 
    187188                                } 
    188189                        ?> 
     
    191192        <tbody> 
    192193                <?php 
    193194                        /* テーブルのデータを出力 */ 
    194                         for ($row = 0; $row < $maxrows; $row++) { /* 行に対応 */ 
     195              do { 
     196                      $maxrows++; 
     197 
    195198                                echo("<tr>\n"); 
    196                                 /* pg_fetch_row で一行取り出す */ 
    197                                 $rowdata = pg_fetch_row($rs, $row); 
    198199                                /* 1列目にリンクを張る */ 
    199200                                echo("<td><a href=\"edit.php?q_code=" . 
    200201                                     urlencode($rowdata[0]) . "\">" . 
     
    203204                                        echo("<td>".htmlspecialchars($rowdata[$col])."<br></td>\n"); 
    204205                                } 
    205206                                echo("</tr>\n"); 
    206                        } 
     207              } while ($rowdata = $rs->fetch()); 
    207208                ?> 
    208209        </tbody> 
    209210</table> 
     
    212213        } 
    213214 
    214215        /* 指定したコードのデータを表示 */ 
    215        function m_viewdata($con, $code) { 
     216function m_viewdata($dbh, $code) { 
    216217                /* コードに該当するデータを検索 */ 
     218/* 
    217219                $query = " 
    218220select p.code 
    219221      ,p.name 
     
    224226      ,to_char(p.editdate, 'YYYY/MM/DD HH24:MI:SS') as editdate 
    225227  from inet_profile p left join inet_job s on p.job = s.code 
    226228 where p.code = $code"; 
    227                 $rs = m_query($con, $query, "個人情報の取得に失敗しました。"); 
    228                 if (pg_num_rows($rs) == 0) { 
     229*/ 
     230        $query = " 
     231select p.code 
     232      ,p.name 
     233      ,p.email 
     234      ,p.pseudonym 
     235      ,s.name as job 
     236      ,p.profile 
     237      ,datetime(p.editdate) as editdate 
     238  from inet_profile p left join inet_job s on p.job = s.code 
     239 where p.code = $code"; 
     240        $rs = m_query($dbh, $query, "個人情報の取得に失敗しました。"); 
     241        $rowdata = $rs->fetch(); 
     242        if (! $rowdata) { 
    229243                        echo("<p class=\"msg\">データが存在しません</p>\n"); 
    230244                        return FALSE; 
    231245                } 
    232246                 
    233247                /* フィールド数 */ 
    234                 $maxcols = pg_num_fields($rs); 
    235                 /* 先頭行 */ 
    236                 $rowdata = pg_fetch_row($rs, 0); 
     248        $maxcols = $rs->columnCount(); 
    237249                ?> 
    238250<table class="view" summary="データベース上のデータを表示" border="1"> 
    239251        <tr> 
    240                 <td class="name"><?= htmlspecialchars(pg_field_name($rs, 1)) ?></td> 
     252             <?php $meta = $rs->getColumnMeta(1); ?> 
     253             <td class="name"><?= htmlspecialchars($meta["name"]) ?></td> 
    241254                <td><a href="edit.php?q_code=<?= $rowdata[0] ?>" 
    242255                     ><?= htmlspecialchars($rowdata[1]) ?></a></td> 
    243256        </tr> 
    244         <?php for ($col = 2; $col < $maxcols; $col++) { ?> 
     257             <?php for ($col = 2; $col < $maxcols; $col++) { 
     258                $meta = $rs->getColumnMeta($col); ?> 
    245259        <tr> 
    246                <td class="name"><?= htmlspecialchars(pg_field_name($rs, $col)) ?></td> 
     260            <td class="name"><?= htmlspecialchars($meta["name"]) ?></td> 
    247261                <td><?= htmlspecialchars($rowdata[$col]) ?></td> 
    248262        </tr> 
    249263        <?php } ?> 
    250264</table> 
    251265                <?php 
    252266                /* クエリーを解放 */ 
    253                 pg_free_result($rs); 
    254                  
     267      $rs = null; 
    255268                return TRUE; 
    256269        } 
    257270         
     
    293306ORDER BY foltia_epg.startdatetime  ASC 
    294307        "; 
    295308        $rs = m_query($con, $query, "DBクエリに失敗しました"); 
    296         $maxrows = pg_num_rows($rs); 
    297 if ($maxrows == 0) { 
     309        $rowdata = $rs->fetch(); 
     310       if (! $rowdata) { 
    298311                print("番組データがありません<BR>");                        
    299312}else{ 
    300313print "<table width=\"100%\"  border=\"0\">\n"; 
    301314//print "<ul><!-- ($maxrows) $query -->\n"; 
    302315 
    303 for ($row = 0; $row < $maxrows; $row++) {  
    304           
    305 $rowdata = pg_fetch_row($rs, $row); 
    306  
     316                do { 
    307317$printstarttime = substr($rowdata[0],8,2) . ":" .  substr($rowdata[0],10,2); 
    308318$tdclass = "t".substr($rowdata[0],8,2) .  substr($rowdata[0],10,2); 
    309319$title = htmlspecialchars($rowdata[3]); 
     
    322332$printstarttime  <A HREF=\"./reserveepg.php?epgid=$epgid\">$title</A> $desc($rowdata[0] - $rowdata[1]) 
    323333</li>\n"; 
    324334*/ 
    325 }//for 
     335                } while ($rowdata = $rs->fetch());//do 
    326336//print "</ul>\n"; 
    327337print "</table>\n"; 
    328338 
     
    556566WHERE foltia_envpolicy.name  = '$name'   
    557567        "; 
    558568        $useraccount = m_query($con, $query, "DBクエリに失敗しました"); 
    559         $useraccountrows = pg_num_rows($useraccount); 
     569                $rowdata = $useraccount->fetch(); 
     570                if (! $rowdata) { 
     571                        header("HTTP/1.0 401 Unauthorized"); 
     572                        redirectlogin(); 
     573                } 
    560574         
    561         if ($useraccountrows == 1 ){ 
    562                 $rowdata = pg_fetch_row($useraccount, 0); 
    563575                $memberid = $rowdata[0]; 
    564576                $userclass = $rowdata[1]; 
    565577                $username =  $rowdata[2]; 
    566578                $dbpasswd = $rowdata[3]; 
    567         }else{ 
     579 
     580                $rowdata = $useraccount->fetch(); 
     581                if ($rowdata) { 
    568582                header("HTTP/1.0 401 Unauthorized"); 
    569                 //print "<!-- DEBUG DB record error ($useraccountrows)-->"; 
    570583                redirectlogin(); 
    571         }//end if 
    572  
     584                } 
    573585 
    574586// passwdをdbから取りだし 
    575587if ($userclass == 0){ 
     
    626638WHERE foltia_envpolicy.name  = '$username'   
    627639        "; 
    628640                $useraccount = m_query($con, $query, "DBクエリに失敗しました"); 
    629         $useraccountrows = pg_num_rows($useraccount); 
     641                $rowdata = $useraccount->fetch(); 
     642                if (! $rowdata) { 
     643                        return (99); 
     644                } 
    630645         
    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 
     646                $userclass = $rowdata[1]; 
     647 
     648                $rowdata = $useraccount->fetch(); 
     649                if ($rowdata) { 
     650                        return (99); 
     651                } 
     652 
     653                return ($userclass); 
    638654         
    639655}else{ 
    640656        return (0);//環境ポリシー使わないときはつねに特権モード 
     
    654670WHERE foltia_envpolicy.name  = '$username'   
    655671        "; 
    656672                $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{ 
     673                $rowdata = $useraccount->fetch(); 
     674                if (! $rowdata) { 
    664675        return (-1);//エラー 
    665         }//end if 
     676                } 
     677 
     678                $memberid = $rowdata[0]; 
     679 
     680                $rowdata = $useraccount->fetch(); 
     681                if ($rowdata) { 
     682                        return (-1); 
     683                } 
     684 
     685                return ($memberid); 
    666686         
    667687}else{ 
    668688        return (0);//環境ポリシー使わないときはつねに特権モード 
     
    681701WHERE foltia_envpolicy.memberid  = '$memberid'   
    682702        "; 
    683703                $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]); 
    689         }else{ 
     704                $rowdata = $useraccount->fetch(); 
     705                if (! $rowdata) { 
    690706        return ("");//エラー 
    691         }//end if 
     707               } 
    692708         
    693 }else{ 
     709                $name = $rowdata[2]; 
     710 
     711                $rowdata = $useraccount->fetch(); 
     712                if ($rowdata) { 
    694713        return (""); 
    695 }//end if 
     714                } 
    696715 
     716                return ($name); 
    697717 
     718        }else{ 
     719                return (""); 
     720        }//end if 
    698721 
    699722}//end function getmemberid2name 
    700723 
  • foltia/install/php/graytable.css

    old new  
    1 body * {margin:0px;padding:0px;border:0px;} 
     1// body * {margin:0px;padding:0px;border:0px;} 
    22 
    33body { 
    44        color: #555; 
  • foltia/install/php/index.php

    old new  
    7171LIMIT 1000 
    7272        "; 
    7373        $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); 
     74$rowdata = $reservedrssametid->fetch(); 
     75if ($rowdata) { 
     76        do { 
    7977                $reservedpidsametid[] = $rowdata[7]; 
    80         } 
     78        } while ($rowdata = $reservedrssametid->fetch()); 
     79 
    8180        $rowdata = ""; 
    82         $rrow = "";  
    8381        }else{ 
    84         $reservedpidsametid = ""
     82        $reservedpidsametid = array()
    8583        }//end if 
     84$reservedrssametid->closeCursor(); 
    8685 
    8786//録画番組検索 
    8887$query = " 
    8988SELECT 
    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   
     89 foltia_program.tid, stationname, foltia_program.title, 
     90 foltia_subtitle.countno, foltia_subtitle.subtitle, 
     91 foltia_subtitle.startdatetime as x, foltia_subtitle.lengthmin, 
     92 foltia_tvrecord.bitrate, foltia_subtitle.pid 
    9993FROM foltia_subtitle , foltia_program ,foltia_station ,foltia_tvrecord 
    10094WHERE 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 
    10195AND foltia_subtitle.enddatetime >= '$now' 
    10296UNION 
    10397SELECT 
    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   
     98 foltia_program.tid, stationname, foltia_program.title, 
     99 foltia_subtitle.countno, foltia_subtitle.subtitle, 
     100 foltia_subtitle.startdatetime, foltia_subtitle.lengthmin, 
     101 foltia_tvrecord.bitrate, foltia_subtitle.pid 
    113102FROM foltia_tvrecord 
    114103LEFT OUTER JOIN foltia_subtitle on (foltia_tvrecord.tid = foltia_subtitle.tid ) 
    115104LEFT OUTER JOIN foltia_program on (foltia_tvrecord.tid = foltia_program.tid ) 
    116105LEFT OUTER JOIN foltia_station on (foltia_subtitle.stationid = foltia_station.stationid ) 
    117106WHERE foltia_tvrecord.stationid = 0 AND 
    118 foltia_subtitle.enddatetime >= '$now' ORDER BY \"startdatetime\" ASC  
     107 foltia_subtitle.enddatetime >= '$now' ORDER BY x ASC 
    119108LIMIT 1000 
    120109        "; 
    121110 
    122111        $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); 
     112$rowdata = $reservedrs->fetch(); 
     113if ($rowdata) { 
     114        do { 
    128115                $reservedpid[] = $rowdata[8]; 
    129         } 
     116        } while ($rowdata = $reservedrs->fetch()); 
    130117        }else{ 
    131         $reservedpid = ""
     118        $reservedpid = array()
    132119        }//end if 
    133120 
    134121$mode = getgetform(mode); 
     
    137124//新番組表示モード 
    138125        $query = " 
    139126        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    
     127 foltia_program.tid, stationname, foltia_program.title, 
     128 foltia_subtitle.countno, foltia_subtitle.subtitle, 
     129 foltia_subtitle.startdatetime, foltia_subtitle.lengthmin, 
     130 foltia_subtitle.pid, foltia_subtitle.startoffset 
    149131FROM foltia_subtitle , foltia_program ,foltia_station   
    150132WHERE foltia_program.tid = foltia_subtitle.tid AND foltia_station.stationid = foltia_subtitle.stationid  
    151133 AND foltia_subtitle.enddatetime >= '$now'  AND foltia_subtitle.countno = '1'  
    152134ORDER BY foltia_subtitle.startdatetime  ASC  
    153135LIMIT 1000 
    154136        "; 
    155         $rs = m_query($con, $query, "DBクエリに失敗しました"); 
    156         $maxrows = pg_num_rows($rs); 
    157  
    158  
    159137}else{ 
    160138        $query = " 
    161139        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    
     140 foltia_program.tid, stationname, foltia_program.title, 
     141 foltia_subtitle.countno, foltia_subtitle.subtitle, 
     142 foltia_subtitle.startdatetime, foltia_subtitle.lengthmin, 
     143 foltia_subtitle.pid, foltia_subtitle.startoffset 
    171144FROM foltia_subtitle , foltia_program ,foltia_station   
    172145WHERE foltia_program.tid = foltia_subtitle.tid AND foltia_station.stationid = foltia_subtitle.stationid  
    173146 AND foltia_subtitle.enddatetime >= '$now'   
    174147ORDER BY foltia_subtitle.startdatetime  ASC  
    175148LIMIT 1000 
    176149        "; 
    177         $rs = m_query($con, $query, "DBクエリに失敗しました"); 
    178         $maxrows = pg_num_rows($rs); 
    179  
    180150}//end if 
    181151 
    182 if ($maxrows == 0) { 
     152$rs = m_query($con, $query, "DBクエリに失敗しました"); 
     153$rowdata = $rs->fetch(); 
     154if (! $rowdata) { 
    183155header("Status: 404 Not Found",TRUE,404); 
    184156printtitle(); 
    185157print "<body BGCOLOR=\"#ffffff\" TEXT=\"#494949\" LINK=\"#0047ff\" VLINK=\"#000000\" ALINK=\"#c6edff\" > 
     
    210182 
    211183<? 
    212184                /* フィールド数 */ 
    213                $maxcols = pg_num_fields($rs); 
     185    $maxcols = $rs->columnCount(); 
    214186                ?> 
    215187  <table BORDER="0" CELLPADDING="0" CELLSPACING="2" WIDTH="100%"> 
    216188        <thead> 
     
    229201        <tbody> 
    230202                <?php 
    231203                        /* テーブルのデータを出力 */ 
    232                         for ($row = 0; $row < $maxrows; $row++) { /* 行に対応 */ 
    233                                 /* pg_fetch_row で一行取り出す */ 
    234                                 $rowdata = pg_fetch_row($rs, $row); 
    235  
     204     do { 
    236205//他局で同一番組録画済みなら色変え 
    237206if (in_array($rowdata[7], $reservedpidsametid)) { 
    238207$rclass = "reservedtitle"; 
     
    282251                                        echo("<td>".htmlspecialchars($rowdata[6])."<br></td>\n"); 
    283252 
    284253                                echo("</tr>\n"); 
    285                         } 
     254     } while ($rowdata = $rs->fetch()); 
    286255                ?> 
    287256        </tbody> 
    288257</table> 
  • foltia/install/php/listreserve.php

    old new  
    6161} 
    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 
    7872AND foltia_subtitle.enddatetime >= '$now' 
    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 
    9482LEFT OUTER JOIN foltia_subtitle on (foltia_tvrecord.tid = foltia_subtitle.tid ) 
    9583LEFT OUTER JOIN foltia_program on (foltia_tvrecord.tid = foltia_program.tid ) 
    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 >= '$now' ORDER BY x ASC 
    9987        "; 
    10088 
    10189        $rs = m_query($con, $query, "DBクエリに失敗しました"); 
    102         $maxrows = pg_num_rows($rs); 
    103                          
    10490 
    10591//チューナー数 
    10692if (getgetnumform(r) != ""){ 
     
    121107<p align="left">録画予約番組放映予定と予約番組名を表示します。</p> 
    122108 
    123109<? 
    124         if ($maxrows == 0) { 
     110     $rowdata = $rs->fetch(); 
     111     if (! $rowdata) { 
    125112                print "番組データがありません<BR>\n";                       
    126113                }else{ 
    127  
    128  
    129114                /* フィールド数 */ 
    130                $maxcols = pg_num_fields($rs); 
     115             $maxcols = $rs->columnCount(); 
    131116                ?> 
    132117  <table BORDER="0" CELLPADDING="0" CELLSPACING="2" WIDTH="100%"> 
    133118        <thead> 
     
    148133        <tbody> 
    149134                <?php 
    150135                        /* テーブルのデータを出力 */ 
    151                        for ($row = 0; $row < $maxrows; $row++) { /* 行に対応 */ 
     136                  do { 
    152137                                echo("<tr>\n"); 
    153                                 /* pg_fetch_row で一行取り出す */ 
    154                                 $rowdata = pg_fetch_row($rs, $row); 
     138 
    155139$pid = htmlspecialchars($rowdata[9]); 
    156140 
    157141$tid = htmlspecialchars($rowdata[0]); 
     
    167151//オンボードチューナー録画 
    168152$query = " 
    169153SELECT 
    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  
     154 foltia_program.tid, stationname, foltia_program.title, 
     155 foltia_subtitle.countno, foltia_subtitle.subtitle, 
     156 foltia_subtitle.startdatetime, foltia_subtitle.lengthmin, 
     157 foltia_tvrecord.bitrate, foltia_subtitle.startoffset, 
     158 foltia_subtitle.pid, foltia_tvrecord.digital 
    181159FROM foltia_subtitle , foltia_program ,foltia_station ,foltia_tvrecord 
    182160WHERE 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 
    183161AND foltia_subtitle.enddatetime > '$rowdata[5]'  
    184162AND foltia_subtitle.startdatetime < '$endtime'   
    185163UNION 
    186164SELECT 
    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  
     165 foltia_program.tid, stationname, foltia_program.title, 
     166 foltia_subtitle.countno, foltia_subtitle.subtitle, 
     167 foltia_subtitle.startdatetime, foltia_subtitle.lengthmin, 
     168 foltia_tvrecord.bitrate, foltia_subtitle.startoffset, 
     169 foltia_subtitle.pid, foltia_tvrecord.digital 
    198170FROM foltia_tvrecord 
    199171LEFT OUTER JOIN foltia_subtitle on (foltia_tvrecord.tid = foltia_subtitle.tid ) 
    200172LEFT OUTER JOIN foltia_program on (foltia_tvrecord.tid = foltia_program.tid ) 
     
    205177        "; 
    206178        $rclass = ""; 
    207179        $overlap = m_query($con, $query, "DBクエリに失敗しました"); 
    208         $overlapmaxrows = pg_num_rows($overlap); 
     180                          $owrowall = $overlap->fetchAll(); 
     181                          $overlapmaxrows = count($owrowall); 
    209182        if ($overlapmaxrows > ($recunits) ){ 
    210183                 
    211184                $owtimeline = array(); 
    212185                 
    213186                for ($rrow = 0; $rrow < $overlapmaxrows ; $rrow++) { 
    214                         $owrowdata = pg_fetch_array($overlap, $rrow)
     187                                         $owrowdata = $owrowall[$rrow]
    215188                        $owtimeline[ $owrowdata['startdatetime'] ] = $owtimeline[ $owrowdata['startdatetime'] ] +1; 
    216189                         
    217190                        $owrend = calcendtime( $owrowdata['startdatetime'], $owrowdata['lengthmin'] ); 
     
    236209$externalinputs = 1; //現状一系統のみ 
    237210$query = " 
    238211SELECT 
    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  
     212 foltia_program.tid, stationname, foltia_program.title, 
     213 foltia_subtitle.countno, foltia_subtitle.subtitle, 
     214 foltia_subtitle.startdatetime, foltia_subtitle.lengthmin, 
     215 foltia_tvrecord.bitrate, foltia_subtitle.startoffset, 
     216 foltia_subtitle.pid, foltia_tvrecord.digital 
    250217FROM foltia_subtitle , foltia_program ,foltia_station ,foltia_tvrecord 
    251218WHERE 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 
    252219AND foltia_subtitle.enddatetime > '$rowdata[5]'  
     
    254221AND  (foltia_station.stationrecch = '0' OR  foltia_station.stationrecch = '-1' )  
    255222UNION 
    256223SELECT 
    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  
     224 foltia_program.tid, stationname, foltia_program.title, 
     225 foltia_subtitle.countno, foltia_subtitle.subtitle, 
     226 foltia_subtitle.startdatetime, foltia_subtitle.lengthmin, 
     227 foltia_tvrecord.bitrate, foltia_subtitle.startoffset, 
     228 foltia_subtitle.pid, foltia_tvrecord.digital 
    268229FROM foltia_tvrecord 
    269230LEFT OUTER JOIN foltia_subtitle on (foltia_tvrecord.tid = foltia_subtitle.tid ) 
    270231LEFT OUTER JOIN foltia_program on (foltia_tvrecord.tid = foltia_program.tid ) 
     
    273234foltia_subtitle.enddatetime > '$rowdata[5]'   
    274235AND foltia_subtitle.startdatetime < '$endtime'   
    275236AND  (foltia_station.stationrecch = '0' OR  foltia_station.stationrecch = '-1' )  
    276  
    277237        "; 
    278238        $eoverlap = m_query($con, $query, "DBクエリに失敗しました"); 
    279         $eoverlapmaxrows = pg_num_rows($eoverlap); 
     239                          $eowrowall = $eoverlap->fetchAll(); 
     240                          $eoverlapmaxrows = count($eowrowall); 
    280241        if ($eoverlapmaxrows > ($externalinputs) ){ 
    281242                 
    282243                $eowtimeline = array(); 
    283244                 
    284245                for ($erow = 0; $erow < $eoverlapmaxrows ; $erow++) { 
    285                         $eowrowdata = pg_fetch_array($eoverlap, $erow)
     246                                         $eowrowdata = $eowrowall[$erow]
    286247                        $eowtimeline[ $eowrowdata['startdatetime'] ] = $eowtimeline[ $eowrowdata['startdatetime'] ] +1; 
    287248                         
    288249                        $eowrend = calcendtime( $eowrowdata['startdatetime'], $eowrowdata['lengthmin'] ); 
     
    358319                                        } 
    359320                                        echo("<br></td>\n"); 
    360321                                echo("</tr>\n"); 
    361                        } 
     322                  } while ($rowdata = $rs->fetch()); 
    362323                ?> 
    363324        </tbody> 
    364325</table> 
     
    373334 
    374335 
    375336<?php 
    376 } //if ($maxrows == 0) { 
    377  
    378  
     337    } //if ($maxrows == 0) 
    379338        $query = " 
    380339SELECT  
    381 foltia_program.tid, 
    382 stationname, 
    383 foltia_program .title , 
    384 foltia_tvrecord.bitrate , 
    385 foltia_tvrecord.stationid ,  
     340 foltia_program.tid, stationname, foltia_program.title, 
     341 foltia_tvrecord.bitrate, foltia_tvrecord.stationid,  
    386342foltia_tvrecord.digital    
    387343FROM  foltia_tvrecord , foltia_program , foltia_station  
    388344WHERE foltia_tvrecord.tid = foltia_program.tid  AND foltia_tvrecord.stationid = foltia_station .stationid  
    389345ORDER BY foltia_program.tid  DESC 
    390346"; 
    391347        $rs = m_query($con, $query, "DBクエリに失敗しました"); 
    392         $maxrows = pg_num_rows($rs); 
    393                          
    394                 if ($maxrows == 0) { 
     348$rowdata = $rs->fetch();                         
     349if (! $rowdata) { 
    395350//なければなにもしない 
    396351                         
    397352                }else{ 
    398                $maxcols = pg_num_fields($rs); 
     353        $maxcols = $rs->columnCount(); 
    399354 
    400355?> 
    401356<p align="left">録画予約番組タイトルを表示します。</p> 
     
    416371        <tbody> 
    417372                <?php 
    418373                        /* テーブルのデータを出力 */ 
    419                         for ($row = 0; $row < $maxrows; $row++) { /* 行に対応 */ 
    420                                 /* pg_fetch_row で一行取り出す */ 
    421                                 $rowdata = pg_fetch_row($rs, $row); 
    422  
     374             do { 
    423375                                $tid = htmlspecialchars($rowdata[0]); 
    424376                                 
    425377                                if ($tid > 0){ 
     
    467419                                        } 
    468420                                echo("\n</tr>"); 
    469421                                }//if tid 0 
    470                        }//for 
     422             } while ($rowdata = $rs->fetch()); 
    471423                }//else 
    472424                ?> 
    473425        </tbody> 
  • foltia/install/php/m.php

    old new  
    9898FROM foltia_station  
    9999WHERE stationid = $recstid"; 
    100100        $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{ 
     101                $recstationname = $stationvalid->fetch(); 
     102                if (! $recstationname) { 
    107103                $errflag = 3; 
    108104                $errmsg = "放送局設定が異常です。"; 
    109105        } 
     
    128124//min pidを探す 
    129125$query = "SELECT min(pid) FROM  foltia_subtitle "; 
    130126        $rs = m_query($con, $query, "DBクエリに失敗しました"); 
    131         $maxrows = pg_num_rows($rs); 
    132         if ($maxrows == 0)
     127                       $rowdata = $rs->fetch(); 
     128                       if (! $rowdata)
    133129        $insertpid = -1 ; 
    134130        }else{ 
    135         $rowdata = pg_fetch_row($rs, 0); 
    136131        $insertpid = $rowdata[0]; 
    137132        $insertpid-- ; 
    138133        } 
    139134// next 話数を探す 
    140135$query = "SELECT max(countno) FROM  foltia_subtitle WHERE tid = 0"; 
    141136        $rs = m_query($con, $query, "DBクエリに失敗しました"); 
    142         $maxrows = pg_num_rows($rs); 
    143         if ($maxrows == 0)
     137                       $rowdata = $rs->fetch(); 
     138                       if (! $rowdata)
    144139        $nextcno = 1 ; 
    145140        }else{ 
    146         $rowdata = pg_fetch_row($rs, 0); 
    147141        $nextcno = $rowdata[0]; 
    148142        $nextcno++ ; 
    149143        } 
     
    214208  <p>録画局: 
    215209<?php 
    216210$query = " 
    217 SELECT stationid,stationname,stationrecch ,digitalch  
     211SELECT stationid as x, stationname, stationrecch, digitalch 
    218212FROM foltia_station  
    219213WHERE stationrecch > 0  
    220214UNION  
    221215SELECT DISTINCT  stationid,stationname,stationrecch ,digitalch  
    222216FROM  foltia_station  
    223217WHERE digitalch > 0 
    224 ORDER BY \"stationid\" ASC"; 
     218 ORDER BY x ASC"; 
    225219 
    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); 
     220$stationcount = $stations->rowCount(); 
     221                   $rowdata = $stations->fetch(); 
     222                   if ($rowdata) { 
     223                           do { 
    232224                        if ($recstid == $rowdata[0]){ 
    233225                        print " <input name=\"recstid\" type=\"radio\" value=\"$rowdata[0]\" checked />  $rowdata[1] ($rowdata[2]ch) \n"; 
    234226                        }else{ 
    235227                                print " <input name=\"recstid\" type=\"radio\" value=\"$rowdata[0]\" />  $rowdata[1] ($rowdata[2]ch) \n"; 
    236228                        } 
    237         } 
     229                          } while ($rowdata = $stations->fetch()); 
    238230}else{ 
    239231print "放送局データベースが正しくセットアップされていません。録画可能局がありません"; 
    240232} 
     
    246238ORDER BY \"stationid\" ASC"; 
    247239 
    248240        $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); 
     241$rowdata = $stations->fetch();   
     242if ($rowdata) { 
     243        do { 
    254244                if ($rowdata[0] != 0){ 
    255245                        if ($recstid == $rowdata[0]){ 
    256246                        print " <input name=\"recstid\" type=\"radio\" value=\"$rowdata[0]\" checked />  $rowdata[1] \n"; 
     
    259249                        } 
    260250 
    261251                } 
    262         } 
     252        } while ($rowdata = $stations->fetch()); 
    263253} 
    264254/* 
    265255print "<p>デジタル録画を優先:"; 
  • foltia/install/php/reservecomp.php

    old new  
    6865//タイトル取得 
    6966        $query = "select title from foltia_program where tid='$tid'"; 
    7067        $rs = m_query($con, $query, "DBクエリに失敗しました"); 
    71         $maxrows = pg_num_rows($rs); 
    72                          
    73                 if ($maxrows == 0) { 
     68$rowdata = $rs->fetch(); 
     69if (! $rowdata) { 
    7470                $title = "(未登録)"; 
    7571                }else{ 
    76                 $rowdata = pg_fetch_row($rs, 0); 
    7772                $title = htmlspecialchars($rowdata[0]); 
    7873                } 
    7974 
     
    129124 
    130125} 
    131126        $rs = m_query($con, $query, "DBクエリに失敗しました"); 
    132         $maxrows = pg_num_rows($rs); 
    133                          
    134                 if ($maxrows == 0) { 
     127$rowdata = $rs->fetch(); 
     128if (! $rowdata) { 
    135129                echo("放映予定はいまのところありません<BR>"); 
    136130                } 
    137131                else{ 
    138                $maxcols = pg_num_fields($rs);           
     132        $maxcols = $rs->columnCount(); 
    139133?> 
    140134  <table BORDER="0" CELLPADDING="0" CELLSPACING="2" WIDTH="100%" BGCOLOR="#bcf1be"> 
    141135        <thead> 
     
    154148        <tbody> 
    155149                <?php 
    156150                        /* テーブルのデータを出力 */ 
    157                         for ($row = 0; $row < $maxrows; $row++) { /* 行に対応 */ 
     151       do { 
    158152                                echo("<tr>\n"); 
    159                                 /* pg_fetch_row で一行取り出す */ 
    160                                 $rowdata = pg_fetch_row($rs, $row); 
    161  
    162153                                for ($col = 0; $col < $maxcols; $col++) { /* 列に対応 */ 
    163154                                        echo("<td>".htmlspecialchars($rowdata[$col])."<br></td>\n"); 
    164155                                } 
    165156                                echo("</tr>\n"); 
    166                         } 
     157       } while ($rowdata = $rs->fetch()); 
    167158                }//end if 
    168159                ?> 
    169160        </tbody> 
     
    176167//foltia_tvrecord 書き込み 
    177168//既存が予約あって、新着が全局予約だったら 
    178169if ($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){ 
    188170        //既存局を消す 
    189171                $query = "DELETE  
    190172FROM foltia_tvrecord   
    191173WHERE tid = '$tid'  
    192174"; 
    193175        $rs = m_query($con, $query, "DBクエリに失敗しました"); 
    194                 } 
    195176}//endif 
    196177 
    197178        $query = " 
    198179SELECT  
    199  *  
     180count(*)  
    200181FROM foltia_tvrecord   
    201182WHERE tid = '$tid'  AND stationid = '$station'  
    202183"; 
    203184        $rs = m_query($con, $query, "DBクエリに失敗しました"); 
    204         $maxrows = pg_num_rows($rs); 
    205  
     185        $maxrows = $rs->fetchColumn(0); 
    206186                if ($maxrows == 0) { //新規追加 
    207187                                $query = "INSERT INTO  foltia_tvrecord  values ('$tid','$station','$bitrate','$usedigital')"; 
    208188                                $rs = m_query($con, $query, "DB書き込みに失敗しました"); 
  • foltia/install/php/reserveepg.php

    old new  
    5856        WHERE epgid='$epgid' AND foltia_station.ontvcode = foltia_epg.ontvchannel 
    5957        ";//4812 
    6058        $rs = m_query($con, $query, "DBクエリに失敗しました"); 
    61         $maxrows = pg_num_rows($rs); 
    62                          
    63                 if ($maxrows == 0) { 
     59$rowdata = $rs->fetch(); 
     60if (! $rowdata) { 
    6461                die_exit("登録番組がありません<BR>"); 
    6562                } 
    66                 $rowdata = pg_fetch_row($rs, 0); 
     63 
    6764                //$title = htmlspecialchars($rowdata[0]); 
    6865?> 
    6966<body BGCOLOR="#ffffff" TEXT="#494949" LINK="#0047ff" VLINK="#000000" ALINK="#c6edff" > 
     
    135132//重複確認 
    136133$query = " 
    137134SELECT 
    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   
     135 foltia_program.title, foltia_program.tid, stationname, 
     136 foltia_station.stationid, foltia_subtitle.countno, 
     137 foltia_subtitle.subtitle, foltia_subtitle.startdatetime, 
     138 foltia_subtitle.lengthmin, foltia_tvrecord.bitrate, 
     139 foltia_subtitle.startoffset, foltia_subtitle.pid 
    149140FROM foltia_subtitle , foltia_program ,foltia_station ,foltia_tvrecord 
    150141WHERE 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 
    151142AND foltia_subtitle.startdatetime ='$startfoltime'   
     
    153144AND foltia_station.stationid = '$stationid'    
    154145UNION 
    155146SELECT 
    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   
     147 foltia_program.title, foltia_program.tid, stationname, 
     148 foltia_station.stationid, foltia_subtitle.countno, 
     149 foltia_subtitle.subtitle, foltia_subtitle.startdatetime, 
     150 foltia_subtitle.lengthmin, foltia_tvrecord.bitrate, 
     151 foltia_subtitle.startoffset, foltia_subtitle.pid 
    167152FROM foltia_tvrecord 
    168153LEFT OUTER JOIN foltia_subtitle on (foltia_tvrecord.tid = foltia_subtitle.tid ) 
    169154LEFT OUTER JOIN foltia_program on (foltia_tvrecord.tid = foltia_program.tid ) 
     
    174159AND foltia_station.stationid =  '$stationid'   
    175160"; 
    176161 
    177  
    178  
    179         $rs = m_query($con, $query, "DBクエリに失敗しました"); 
    180         $maxrows = pg_num_rows($rs); 
    181  
    182162//print "<!--$query \n $maxrows\n -->"; 
    183163 
    184164print "<form name=\"recordingsetting\" method=\"POST\" action=\"reserveepgcomp.php\">\n"; 
    185165 
    186                 if ($maxrows == 0) { 
     166$rs = m_query($con, $query, "DBクエリに失敗しました"); 
     167$chkoverwrap = $rs->fetch(); 
     168if (! $chkoverwrap) { 
    187169                //重複なし 
    188170                print "<input type=\"submit\" value=\"予約\" ><br>\n"; 
    189171                }else{ 
    190                 $chkoverwrap = pg_fetch_row($rs, 0); 
    191172                $prereservedtitle = htmlspecialchars($chkoverwrap[0]); 
    192173                $tid =  htmlspecialchars($chkoverwrap[1]); 
    193174                $pid =  htmlspecialchars($chkoverwrap[2]); 
  • foltia/install/php/reserveepgcomp.php

    old new  
    7269//min pidを探す 
    7370$query = "SELECT min(pid) FROM  foltia_subtitle "; 
    7471        $rs = m_query($con, $query, "DBクエリに失敗しました"); 
    75         $maxrows = pg_num_rows($rs); 
    76         if ($maxrows == 0)
     72        $rowdata = $rs->fetch(); 
     73        if (! $rowdata)
    7774        $insertpid = -1 ; 
    7875        }else{ 
    79         $rowdata = pg_fetch_row($rs, 0); 
    80          
    8176        $insertpid = $rowdata[0]; 
    8277                if ($insertpid > 0){ 
    8378                $insertpid = -1; 
     
    8883// next 話数を探す 
    8984$query = "SELECT max(countno) FROM  foltia_subtitle WHERE tid = 0"; 
    9085        $rs = m_query($con, $query, "DBクエリに失敗しました"); 
    91         $maxrows = pg_num_rows($rs); 
    92         if ($maxrows == 0)
     86        $rowdata = $rs->fetch(); 
     87        if (! $rowdata)
    9388        $nextcno = 1 ; 
    9489        }else{ 
    95         $rowdata = pg_fetch_row($rs, 0); 
    9690        $nextcno = $rowdata[0]; 
    9791        $nextcno++ ; 
    9892        } 
  • foltia/install/php/reserveprogram.php

    old new  
    5452//タイトル取得 
    5553        $query = "select title from foltia_program where tid='$tid'"; 
    5654        $rs = m_query($con, $query, "DBクエリに失敗しました"); 
    57         $maxrows = pg_num_rows($rs); 
    58                          
    59                 if ($maxrows == 0) { 
     55$rowdata = $rs->fetch(); 
     56if (! $rowdata) { 
    6057                die_exit("登録番組がありません<BR>"); 
    6158                } 
    62                 $rowdata = pg_fetch_row($rs, 0); 
     59 
    6360                $title = htmlspecialchars($rowdata[0]); 
    6461?> 
    6562<body BGCOLOR="#ffffff" TEXT="#494949" LINK="#0047ff" VLINK="#000000" ALINK="#c6edff" > 
     
    104101"; 
    105102 
    106103        $rs = m_query($con, $query, "DBクエリに失敗しました"); 
    107         $maxrows = pg_num_rows($rs); 
    108                          
    109                 if ($maxrows == 0) { 
     104$rowdata = $rs->fetch(); 
     105if (! $rowdata) { 
    110106                echo("放映局情報がまだはいってません<BR>"); 
    111107                } 
    112108                else{ 
    113                $maxcols = pg_num_fields($rs); 
     109        $maxcols = $rs->columnCount(); 
    114110                 
    115111                        echo("<select name=\"station\">\n"); 
    116112                        /* テーブルのデータを出力 */ 
    117                         for ($row = 0; $row < $maxrows; $row++) { /* 行に対応 */ 
    118                                 /* pg_fetch_row で一行取り出す */ 
    119                                 $rowdata = pg_fetch_row($rs, $row); 
     113        do { 
    120114                                echo("<option value=\""); 
    121115                                echo(htmlspecialchars($rowdata[0])); 
    122116                                echo("\">"); 
    123117                                echo(htmlspecialchars($rowdata[1])); 
    124118                                echo("</option>\n"); 
    125                        }//for 
     119        } while ($rowdata = $rs->fetch()); 
    126120                        echo("<option value=\"0\">全局</option>\n</select>\n"); 
    127121                }//endif                 
    128122        ?> 
     
    185179ORDER BY foltia_subtitle.startdatetime  ASC 
    186180"; 
    187181        $rs = m_query($con, $query, "DBクエリに失敗しました"); 
    188         $maxrows = pg_num_rows($rs); 
    189                          
    190                 if ($maxrows == 0) { 
     182$rowdata = $rs->fetch(); 
     183if (! $rowdata) { 
    191184                echo("放映予定はありません<BR>"); 
    192185                } 
    193186                else{ 
    194                $maxcols = pg_num_fields($rs);           
     187        $maxcols = $rs->columnCount(); 
    195188?> 
    196189  <table BORDER="0" CELLPADDING="0" CELLSPACING="2" WIDTH="100%" BGCOLOR="#bcf1be"> 
    197190        <thead> 
     
    209202        <tbody> 
    210203                <?php 
    211204                        /* テーブルのデータを出力 */ 
    212                         for ($row = 0; $row < $maxrows; $row++) { /* 行に対応 */ 
     205       do { 
    213206                                echo("<tr>\n"); 
    214                                 /* pg_fetch_row で一行取り出す */ 
    215                                 $rowdata = pg_fetch_row($rs, $row); 
    216  
    217207                                for ($col = 0; $col < $maxcols; $col++) { /* 列に対応 */ 
    218208                                        if ($col == 3){ 
    219209                                        echo("<td>".htmlspecialchars(foldate2print($rowdata[$col]))."<br></td>\n"); 
     
    222212                                        } 
    223213                                } 
    224214                                echo("</tr>\n"); 
    225                         } 
     215       } while ($rowdata = $rs->fetch()); 
    226216                }//end if 
    227217                ?> 
    228218        </tbody> 
  • foltia/install/php/selectcaptureimage.php

    old new  
    7775  
    7876        "; 
    7977        $rs = m_query($con, $query, "DBクエリに失敗しました"); 
    80 $rows = pg_num_rows($rs); 
    81 if ($rows == 0)
     78$rowdata = $rs->fetch(); 
     79if (! $rowdata)
    8280        print "  <p align=\"left\"><font color=\"#494949\" size=\"6\">キャプチャ画像</font></p> 
    8381  <hr size=\"4\"> 
    8482<p align=\"left\"> 
     
    8684"; 
    8785 
    8886}else{ 
    89 $rowdata = pg_fetch_row($rs, 0); 
    90  
    9187print "  <p align=\"left\"><font color=\"#494949\" size=\"6\">キャプチャ画像</font></p> 
    9288  <hr size=\"4\"> 
    9389<p align=\"left\">"; 
  • foltia/install/php/showlib.php

    old new  
    8484"; 
    8585 
    8686$rs = m_query($con, $query, "DBクエリに失敗しました"); 
    87  
    88 $maxrows = pg_num_rows($rs); 
    89  
    90 if ($maxrows > 0 ){ 
     87$rowdata = $rs->fetch(); 
     88if ($rowdata) { 
    9189if(ereg("iPhone",$useragent)){ 
    9290        print "<ul id=\"home\" title=\"録画ライブラリ表示\" selected=\"true\">"; 
    9391}else{ 
     
    104102        <tbody> 
    105103"; 
    106104} 
    107 for ($row = 0; $row < $maxrows; $row++) { 
    108         $rowdata = pg_fetch_row($rs, $row); 
     105        do { 
    109106$title = $rowdata[1]; 
    110107$counts = $rowdata[2]; 
    111108$tid = htmlspecialchars($rowdata[0]); 
     
    124121</tr>\n 
    125122"; 
    126123} 
    127 }//for 
     124        } while ($rowdata = $rs->fetch()); 
    128125 
    129126if(ereg("iPhone",$useragent)){ 
    130127        print "</ul>\n</body>\n</html>\n"; 
     
    159155WHERE foltia_program.tid = $filesplit[0]  
    160156"; 
    161157$rs = m_query($con, $query, "DBクエリに失敗しました"); 
    162 $rowdata = pg_fetch_row($rs, $row); 
     158$rowdata = $rs->fetch(); 
    163159//print" $fName./$rowdata[1]/$rowdata[2]/$rowdata[3]<BR>\n"; 
    164160$title = $rowdata[1]; 
    165161 
  • foltia/install/php/showlibc.php

    old new  
    7070WHERE foltia_program.tid = $tid   
    7171"; 
    7272$rs = m_query($con, $query, "DBクエリに失敗しました"); 
    73 $maxrows = pg_num_rows($rs); 
    74 if ($maxrows == 0 )
     73$rowdata = $rs->fetch(); 
     74if (! $rowdata)
    7575 $syobocaldb = `curl "http://cal.syoboi.jp/db?Command=TitleLookup&TID=$tid" | head -2 `; 
    7676$syobocaldb = mb_convert_encoding($syobocaldb, "EUC-JP", "UTF-8"); 
    7777        $syobocaldb = preg_match("/<Title>.*<\/Title>/", $syobocaldb,$title); 
     
    7979        $title = strip_tags($title); 
    8080        $title =  htmlspecialchars($title) ; 
    8181}else{ 
    82 $rowdata = pg_fetch_row($rs, 0); 
    8382$title = $rowdata[0]; 
    8483$title =  htmlspecialchars($title) ; 
    8584} 
     
    148146 
    149147$rs = ""; 
    150148$rs = m_query($con, $query, "DBクエリに失敗しました"); 
    151 $maxrows = pg_num_rows($rs); 
    152 if ($maxrows > 0 )
     149$rowdata = $rs->fetch(); 
     150if ($rowdata)
    153151if(ereg("iPhone",$useragent)){ 
    154152        print "<ul id=\"home\" title=\"$title\" selected=\"true\">"; 
    155153}else{ 
     
    158156        <tbody> 
    159157"; 
    160158} 
    161 for ($row = 0; $row < $maxrows; $row++) { 
    162         $rowdata = pg_fetch_row($rs, $row); 
    163  
     159        do { 
    164160$title = $rowdata[1]; 
    165161 
    166162if ($rowdata[2]== "" ){ 
     
    194190$onairdate = "$day $time"; 
    195191} 
    196192//Starlight Breaker向け拡張 
    197 //$debug_pg_num_rows = pg_num_rows ($rs ); 
     193//$debug_pg_num_rows = $rs ->rowCount(); 
    198194$caplink = ""; 
    199195 
    200 if (($sbpluginexist == 1) && (pg_num_rows ($rs ) > 0))
     196               if ($sbpluginexist == 1)
    201197 //$capimgpath = htmlspecialchars(preg_replace("/.m2p/", "", $rowdata[5])); 
    202198 $capimgpath = htmlspecialchars(preg_replace("/.m2./", "", $rowdata[5])); 
    203199         
     
    243239 
    244240}//endif iPhone 
    245241 
    246 }//for 
     242        } while ($rowdata = $rs->fetch()); 
    247243}else{ 
    248244print "録画ファイルがありません<br>\n"; 
    249245}//if 
  • foltia/install/php/showplaylist.php

    old new  
    117113 AND foltia_subtitle.tid = $filesplit[0]  
    118114"; 
    119115$rs = m_query($con, $query, "DBクエリに失敗しました"); 
    120 $rowdata = pg_fetch_row($rs, $row); 
     116                                $rall = $rs->fetchAll(); 
     117                                $rowdata = $rall[$row]; 
    121118//print" $fName./$rowdata[1]//$rowdata[2]<BR>\n"; 
    122119$title = $rowdata[1]; 
    123120$subtitle = ""; 
     
    133129 AND foltia_subtitle.countno = $filesplit[1]  
    134130"; 
    135131$rs = m_query($con, $query, "DBクエリに失敗しました"); 
    136 $rowdata = pg_fetch_row($rs, $row); 
     132                                $rall = $rs->fetchAll(); 
     133                                $rowdata = $rall[$row]; 
    137134//print" $fName./$rowdata[1]/$rowdata[2]/$rowdata[3]<BR>\n"; 
    138135$title = $rowdata[1]; 
    139136$count = $rowdata[2]; 
     
    197193} 
    198194 
    199195$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  
     196$rowdata = $rs->fetch(); 
     197if ($rowdata) { 
     198        do { 
    206199$tid = htmlspecialchars($rowdata[0]); 
    207200$title = htmlspecialchars($rowdata[1]); 
    208201$count = htmlspecialchars($rowdata[2]); 
     
    234227        } 
    235228print "</tr>\n 
    236229"; 
    237 }//for 
     230        } while ($rowdata = $rs->fetch()); 
    238231}else{ 
    239232print " 
    240233<tr> 
     
    262254"; 
    263255 
    264256$rs = m_query($con, $query, "DBクエリに失敗しました"); 
    265 $maxrows = pg_num_rows($rs); 
    266  
    267  
    268 if ($maxrows > 0){ 
     257        $rowdata = $rs->fetch(); 
     258        if ($rowdata) { 
    269259print "<hr> 
    270260<p align=\"left\">未読タイトルを表示します。<br> 
    271261  <table BORDER=\"0\" CELLPADDING=\"0\" CELLSPACING=\"2\" WIDTH=\"100%\"> 
     
    278268        <tbody> 
    279269"; 
    280270 
    281 for ($row = 0; $row < $maxrows; $row++) {  
    282 $rowdata = pg_fetch_row($rs, $row); 
    283  
     271                do { 
    284272$tid = htmlspecialchars($rowdata[0]); 
    285273$title = htmlspecialchars($rowdata[1]); 
    286274 
     
    284272$tid = htmlspecialchars($rowdata[0]); 
    285273$title = htmlspecialchars($rowdata[1]); 
    286274 
    287  
    288275print "<tr><td>$tid</td><td>$title</td></tr>\n"; 
    289276 
    290 }//for 
     277                } while ($rowdata = $rs->fetch()); 
    291278print "</tbody></table>\n"; 
    292279}//if maxrows 
    293280}//if title 
  • foltia/install/php/titlelist.php

    old new  
    5151ORDER BY foltia_program.tid  DESC 
    5252        "; 
    5353        $rs = m_query($con, $query, "DBクエリに失敗しました"); 
    54         $maxrows = pg_num_rows($rs); 
    55                          
    56                 if ($maxrows == 0) { 
     54$rowdata = $rs->fetch(); 
     55if (! $rowdata) { 
    5756                die_exit("番組データがありません<BR>"); 
    58                          
    5957                } 
    60  
    6158?> 
    6259 
    6360<body BGCOLOR="#ffffff" TEXT="#494949" LINK="#0047ff" VLINK="#000000" ALINK="#c6edff" > 
     
    7168 
    7269<? 
    7370                /* フィールド数 */ 
    74                $maxcols = pg_num_fields($rs); 
     71$maxcols = $rs->columnCount(); 
    7572                ?> 
    7673  <table BORDER="0" CELLPADDING="0" CELLSPACING="2" WIDTH="100%"> 
    7774        <thead> 
     
    8582        <tbody> 
    8683                <?php 
    8784                        /* テーブルのデータを出力 */ 
    88                         for ($row = 0; $row < $maxrows; $row++) { /* 行に対応 */ 
     85    do { 
    8986                                echo("<tr>\n"); 
    90                                 /* pg_fetch_row で一行取り出す */ 
    91                                 $rowdata = pg_fetch_row($rs, $row); 
     87 
    9288                                //TID 
    9389                                        echo("<td><a href=\"reserveprogram.php?tid=" . 
    9490                                     htmlspecialchars($rowdata[0])  . "\">" . 
     
    9995                                     htmlspecialchars($rowdata[1]) . "</a></td>\n"); 
    10096                                        print "<td><A HREF = \"showlibc.php?tid=".htmlspecialchars($rowdata[0])."\">mp4</A></td>\n"; 
    10197                                echo("</tr>\n"); 
    102                         } 
     98    } while ($rowdata = $rs->fetch()); 
    10399                ?> 
    104100        </tbody> 
    105101</table> 
  • foltia/install/php/view_syabas.php

    old new  
    5957  
    6058        "; 
    6159        $rs = m_query($con, $query, "DBクエリに失敗しました"); 
    62  
    63 $rows = pg_num_rows($rs); 
    64 if ($rows == 0){ 
     60$rowdata = $rs->fetch(); 
     61if (! $rowdata) { 
    6562        print ""; 
    6663        exit; 
    6764}else{ 
    68 $rowdata = pg_fetch_row($rs, 0); 
    69  
    7065$title = $rowdata[2]; 
    7166$episode = $rowdata[3]; 
    7267$subtitle = $rowdata[4]; 
  • foltia/install/php/viewepg.php

    old new  
    9088// $page = 1 ~  
    9189$maxdisplay = 8; 
    9290 
    93         $query = "SELECT stationid, stationname, stationrecch, ontvcode FROM foltia_station WHERE \"ontvcode\" ~~ '%ontvjapan%'  
    94         "; 
     91$query = "SELECT count(*) FROM foltia_station WHERE \"ontvcode\" LIKE '%ontvjapan%'"; 
    9592        $rs = m_query($con, $query, "DBクエリに失敗しました"); 
    96         $maxrows = pg_num_rows($rs); 
    97  
     93$maxrows = $rs->fetchColumn(0); 
    9894if ($maxrows > $maxdisplay){ 
    9995        $pages = ceil($maxrows / $maxdisplay) ; 
    10096} 
     
    137131//・局リスト 
    138132$query = "SELECT stationid, stationname, stationrecch, ontvcode  
    139133FROM foltia_station  
    140 WHERE \"ontvcode\" ~~ '%ontvjapan%'   
     134WHERE \"ontvcode\" LIKE '%ontvjapan%'   
    141135ORDER BY stationid ASC , stationrecch  
    142 OFFSET $offset LIMIT $maxdisplay  
     136LIMIT $maxdisplay OFFSET $offset 
    143137"; 
     138 
    144139$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] ; 
     140while ($rowdata = $slistrs->fetch()) { 
     141        $stationhash[] = $rowdata[3]; 
     142        $snames[] = $rowdata[1]; // headder 
    149143} 
    150144 
    151145//・時間と全順番のハッシュ作る 
     
    157151WHERE foltia_epg.ontvchannel in ( 
    158152        SELECT ontvcode  
    159153        FROM foltia_station  
    160         WHERE \"ontvcode\" ~~ '%ontvjapan%'   
     154        WHERE \"ontvcode\" LIKE '%ontvjapan%'   
    161155        ORDER BY stationid ASC , stationrecch  
    162         OFFSET $offset LIMIT $maxdisplay 
     156        LIMIT $maxdisplay OFFSET $offset 
    163157        ) 
    164158AND startdatetime  >= $start   
    165159AND startdatetime  < $epgend   
     
    169163 
    170164//print "$query<br>\n"; 
    171165 
    172 $colmnums =  pg_num_rows($rs); 
    173 if ($colmnums == 0)
     166$rowdata = $rs->fetch(); 
     167if (! $rowdata)
    174168//番組データがない 
    175169$colmnums = 2; 
    176170}else{ 
    177         for ($i=0 ; $i < $colmnums ; $i++){ 
    178                 $rowdata = pg_fetch_row($rs, $i); 
    179                 $timetablehash["$rowdata[0]"] = ($i + 1); 
     171        $colmnums = 0; 
     172        do { 
     173                $colmnums++; 
     174                $timetablehash[$rowdata[0]] = $colmnums; 
    180175//              print "$rowdata[0]:$i+1 <br>\n"; 
    181         } 
     176        } while ($rowdata = $rs->fetch()); 
    182177} 
    183178//print "colmnums $colmnums <br>\n"; 
    184179 
    185180//・局ごとに縦に配列入れていく 
    186 for ($j=0 ; $j < $stations ; $j++){ 
    187         $rowdata = pg_fetch_row($slistrs, $j); 
    188         $stationname = $rowdata[3]; 
    189  
     181foreach ($stationhash as $stationname) { 
    190182$epgstart = $start ; 
    191183$epgend = calcendtime($start , (8*60)); 
    192184$query = " 
     
    197189startdatetime  < $epgend   
    198190ORDER BY foltia_epg.startdatetime  ASC 
    199191        "; 
    200         $statiodh = m_query($con, $query, "DBクエリに失敗しました"); 
    201         $maxrowsstation = pg_num_rows($statiodh); 
    202  
    203 //print "maxrowsstation $maxrowsstation  stationname $stationname<br>\n"; 
    204192 
    205 if ($maxrowsstation == 0) { 
     193        $statiodh = m_query($con, $query, "DBクエリに失敗しました"); 
     194        $stationrowdata = $statiodh->fetch(); 
     195        if (! $stationrowdata) { 
    206196                //print("番組データがありません<BR>"); 
    207197                $item[0]["$stationname"] =  ">番組データがありません"; 
    208198}else{ 
    209  
    210 for ($srow = 0; $srow < $maxrowsstation ; $srow++) {  
    211           
    212 $stationrowdata = pg_fetch_row($statiodh, $srow); 
    213  
     199                do { 
    214200$printstarttime = substr($stationrowdata[0],8,2) . ":" .  substr($stationrowdata[0],10,2); 
    215201$tdclass = "t".substr($stationrowdata[0],8,2) .  substr($stationrowdata[0],10,2); 
    216202$title = $stationrowdata[3]; 
     
    234220$item["$number"]["$stationname"] =  " id=\"$epgcategory\" onClick=\"location = './reserveepg.php?epgid=$epgid'\"><span id=\"epgstarttime\">$printstarttime</span> <A HREF=\"./reserveepg.php?epgid=$epgid\"><span id=\"epgtitle\">$title</span></A> <span id=\"epgdesc\">$desc</span></span>"; 
    235221}//if 
    236222 
    237 }//for 
     223                } while ($stationrowdata = $statiodh->fetch()); 
    238224}//if 
    239225 
    240226//・局ごとに間隔決定 
     
    290276print "<table>\n<tr>"; 
    291277 
    292278//ヘッダ 
    293 for ($i=0;$i<$stations;$i++){ 
    294         $rowdata = pg_fetch_row($slistrs, $i); 
    295         print "<th>".htmlspecialchars($rowdata[1])."</th>" ; 
     279foreach ($snames as $s) { 
     280        print "<th>".htmlspecialchars($s)."</th>" ; 
    296281} 
    297282//本体 
    298283for ($l = 0 ;$l <  $colmnums; $l++){ 
    299284        print "<tr>"; 
    300         for ($m = 0 ; $m < $stations ; $m++ ){ 
    301                 $stationname = $stationhash[$m]; 
     285        foreach ($stationhash as $stationname) { 
    302286                print_r($item[$l]["$stationname"]); 
    303287        } 
    304288        print "</tr>\n"; 
track feed