Mercurial > epgrec.yaz
annotate getepg.php @ 135:9c5e597ef6c6
mod: ログ機能を追加
author | epgrec@park.mda.or.jp <yoneda@recorder.localnet.mda.or.jp> |
---|---|
date | Sat, 20 Mar 2010 23:59:01 +0900 |
parents | 3bed74eca373 |
children | b3ba2658a228 481e789605e3 |
rev | line source |
---|---|
1 | 1 #!/usr/bin/php |
2 <?php | |
111
3bed74eca373
change: EPG取得並列化が可能かどうかを判定するように変更
epgrec@park.mda.or.jp <yoneda@recorder.localnet.mda.or.jp>
parents:
86
diff
changeset
|
3 $script_path = dirname( __FILE__ ); |
3bed74eca373
change: EPG取得並列化が可能かどうかを判定するように変更
epgrec@park.mda.or.jp <yoneda@recorder.localnet.mda.or.jp>
parents:
86
diff
changeset
|
4 chdir( $script_path ); |
3bed74eca373
change: EPG取得並列化が可能かどうかを判定するように変更
epgrec@park.mda.or.jp <yoneda@recorder.localnet.mda.or.jp>
parents:
86
diff
changeset
|
5 include_once( $script_path . '/config.php'); |
1 | 6 include_once( INSTALL_PATH . '/DBRecord.class.php' ); |
7 include_once( INSTALL_PATH . '/Reservation.class.php' ); | |
8 include_once( INSTALL_PATH . '/Keyword.class.php' ); | |
37
e5f9aa34d06f
change: modify all script for web base setting
yoneda <epgrec@park.mda.or.jp>
parents:
7
diff
changeset
|
9 include_once( INSTALL_PATH . '/Settings.class.php' ); |
111
3bed74eca373
change: EPG取得並列化が可能かどうかを判定するように変更
epgrec@park.mda.or.jp <yoneda@recorder.localnet.mda.or.jp>
parents:
86
diff
changeset
|
10 include_once( INSTALL_PATH . '/storeProgram.inc.php' ); |
1 | 11 |
85 | 12 // 緇剛 |
13 if( ! defined( "BS_EPG_CHANNEL" ) ) define( "BS_EPG_CHANNEL", "211" ); | |
14 if( ! defined( "CS1_EPG_CHANNEL" ) ) define( "CS1_EPG_CHANNEL", "CS8" ); | |
15 if( ! defined( "CS2_EPG_CHANNEL" ) ) define( "CS2_EPG_CHANNEL", "CS24" ); | |
16 | |
17 function check_file( $file ) { | |
18 // <ゃ≦馹 | |
19 if( ! file_exists( $file ) ) return true; | |
20 | |
21 // 1篁ヤ<ゃゃ眼 | |
22 if( (time() - filemtime( $file )) > 3600 ) { | |
23 @unlink( $file ); | |
24 return true; | |
25 } | |
26 | |
27 return false; | |
28 } | |
29 | |
111
3bed74eca373
change: EPG取得並列化が可能かどうかを判定するように変更
epgrec@park.mda.or.jp <yoneda@recorder.localnet.mda.or.jp>
parents:
86
diff
changeset
|
30 // 筝純桁慎羞宴顄帥鴻 |
3bed74eca373
change: EPG取得並列化が可能かどうかを判定するように変更
epgrec@park.mda.or.jp <yoneda@recorder.localnet.mda.or.jp>
parents:
86
diff
changeset
|
31 $use_para = false; |
3bed74eca373
change: EPG取得並列化が可能かどうかを判定するように変更
epgrec@park.mda.or.jp <yoneda@recorder.localnet.mda.or.jp>
parents:
86
diff
changeset
|
32 $use_para = (function_exists( "pcntl_fork" ) && function_exists( "posix_setsid" ) && function_exists( "pcntl_signal" ) && function_exists("pcntl_setpriority")); |
3bed74eca373
change: EPG取得並列化が可能かどうかを判定するように変更
epgrec@park.mda.or.jp <yoneda@recorder.localnet.mda.or.jp>
parents:
86
diff
changeset
|
33 |
3bed74eca373
change: EPG取得並列化が可能かどうかを判定するように変更
epgrec@park.mda.or.jp <yoneda@recorder.localnet.mda.or.jp>
parents:
86
diff
changeset
|
34 |
37
e5f9aa34d06f
change: modify all script for web base setting
yoneda <epgrec@park.mda.or.jp>
parents:
7
diff
changeset
|
35 $settings = Settings::factory(); |
85 | 36 |
37 $temp_xml_bs = $settings->temp_xml."_bs"; | |
38 $temp_xml_cs1 = $settings->temp_xml."_cs1"; | |
39 $temp_xml_cs2 = $settings->temp_xml."_cs2"; | |
40 $temp_xml_gr = $settings->temp_xml."_gr"; | |
41 | |
37
e5f9aa34d06f
change: modify all script for web base setting
yoneda <epgrec@park.mda.or.jp>
parents:
7
diff
changeset
|
42 if( file_exists( $settings->temp_data ) ) @unlink( $settings->temp_data ); |
84
3ec5ca5e56ca
add: EPG取得並列化版を暫定的に標準に
yoneda <yoneda@recorder.localnet.mda.or.jp>
parents:
82
diff
changeset
|
43 |
1 | 44 // BS |
57 | 45 if( $settings->bs_tuners != 0 ) { |
1 | 46 // 牙脂茲с |
70
1363ac056197
fix: getepg get program information duaring CS/BS recording.
yoneda <yoneda@recorder.localnet.mda.or.jp>
parents:
67
diff
changeset
|
47 $num = DBRecord::countRecords( RESERVE_TBL, "WHERE complete = '0' AND (type = 'BS' OR type = 'CS') AND endtime > now() AND starttime < addtime( now(), '00:03:05')" ); |
85 | 48 if( ($num == 0) && check_file($temp_xml_bs) ) { |
49 $cmdline = "CHANNEL=".BS_EPG_CHANNEL." DURATION=180 TYPE=BS TUNER=0 MODE=0 OUTPUT=".$settings->temp_data." ".DO_RECORD . " >/dev/null 2>&1"; | |
1 | 50 exec( $cmdline ); |
85 | 51 $cmdline = $settings->epgdump." /BS ".$settings->temp_data." ".$temp_xml_bs; |
1 | 52 exec( $cmdline ); |
111
3bed74eca373
change: EPG取得並列化が可能かどうかを判定するように変更
epgrec@park.mda.or.jp <yoneda@recorder.localnet.mda.or.jp>
parents:
86
diff
changeset
|
53 if( $use_para ) { |
3bed74eca373
change: EPG取得並列化が可能かどうかを判定するように変更
epgrec@park.mda.or.jp <yoneda@recorder.localnet.mda.or.jp>
parents:
86
diff
changeset
|
54 $cmdline = INSTALL_PATH."/storeProgram.php BS ".$temp_xml_bs." >/dev/null 2>&1 &"; |
3bed74eca373
change: EPG取得並列化が可能かどうかを判定するように変更
epgrec@park.mda.or.jp <yoneda@recorder.localnet.mda.or.jp>
parents:
86
diff
changeset
|
55 exec( $cmdline ); |
3bed74eca373
change: EPG取得並列化が可能かどうかを判定するように変更
epgrec@park.mda.or.jp <yoneda@recorder.localnet.mda.or.jp>
parents:
86
diff
changeset
|
56 } |
3bed74eca373
change: EPG取得並列化が可能かどうかを判定するように変更
epgrec@park.mda.or.jp <yoneda@recorder.localnet.mda.or.jp>
parents:
86
diff
changeset
|
57 else { |
3bed74eca373
change: EPG取得並列化が可能かどうかを判定するように変更
epgrec@park.mda.or.jp <yoneda@recorder.localnet.mda.or.jp>
parents:
86
diff
changeset
|
58 storeProgram( "BS", $temp_xml_bs ); |
3bed74eca373
change: EPG取得並列化が可能かどうかを判定するように変更
epgrec@park.mda.or.jp <yoneda@recorder.localnet.mda.or.jp>
parents:
86
diff
changeset
|
59 if( file_exists( $temp_xml_bs ) ) @unlink( $temp_xml_bs ); |
3bed74eca373
change: EPG取得並列化が可能かどうかを判定するように変更
epgrec@park.mda.or.jp <yoneda@recorder.localnet.mda.or.jp>
parents:
86
diff
changeset
|
60 } |
37
e5f9aa34d06f
change: modify all script for web base setting
yoneda <epgrec@park.mda.or.jp>
parents:
7
diff
changeset
|
61 if( file_exists( $settings->temp_data ) ) @unlink( $settings->temp_data ); |
82
330c83ae8c95
fix: CSのEPG取得時に予約重複チェックを行っていなかったのを修正
yoneda <yoneda@recorder.localnet.mda.or.jp>
parents:
70
diff
changeset
|
62 } |
67
a2c4665b310c
add: CS support (thanks to dakku)
Sushi-k <epgrec@park.mda.or.jp>
parents:
64
diff
changeset
|
63 |
82
330c83ae8c95
fix: CSのEPG取得時に予約重複チェックを行っていなかったのを修正
yoneda <yoneda@recorder.localnet.mda.or.jp>
parents:
70
diff
changeset
|
64 // CS |
330c83ae8c95
fix: CSのEPG取得時に予約重複チェックを行っていなかったのを修正
yoneda <yoneda@recorder.localnet.mda.or.jp>
parents:
70
diff
changeset
|
65 if ($settings->cs_rec_flg != 0) { |
330c83ae8c95
fix: CSのEPG取得時に予約重複チェックを行っていなかったのを修正
yoneda <yoneda@recorder.localnet.mda.or.jp>
parents:
70
diff
changeset
|
66 $num = DBRecord::countRecords( RESERVE_TBL, "WHERE complete = '0' AND (type = 'BS' OR type = 'CS') AND endtime > now() AND starttime < addtime( now(), '00:03:05')" ); |
85 | 67 if( ($num == 0) && check_file($temp_xml_cs1) ) { |
68 $cmdline = "CHANNEL=".CS1_EPG_CHANNEL." DURATION=120 TYPE=CS TUNER=0 MODE=0 OUTPUT=".$settings->temp_data." ".DO_RECORD . " >/dev/null 2>&1"; | |
67
a2c4665b310c
add: CS support (thanks to dakku)
Sushi-k <epgrec@park.mda.or.jp>
parents:
64
diff
changeset
|
69 exec( $cmdline ); |
85 | 70 $cmdline = $settings->epgdump." /CS ".$settings->temp_data." ".$temp_xml_cs1; |
67
a2c4665b310c
add: CS support (thanks to dakku)
Sushi-k <epgrec@park.mda.or.jp>
parents:
64
diff
changeset
|
71 exec( $cmdline ); |
111
3bed74eca373
change: EPG取得並列化が可能かどうかを判定するように変更
epgrec@park.mda.or.jp <yoneda@recorder.localnet.mda.or.jp>
parents:
86
diff
changeset
|
72 if( $use_para ) { |
3bed74eca373
change: EPG取得並列化が可能かどうかを判定するように変更
epgrec@park.mda.or.jp <yoneda@recorder.localnet.mda.or.jp>
parents:
86
diff
changeset
|
73 $cmdline = INSTALL_PATH."/storeProgram.php CS ".$temp_xml_cs1." >/dev/null 2>&1 &"; |
3bed74eca373
change: EPG取得並列化が可能かどうかを判定するように変更
epgrec@park.mda.or.jp <yoneda@recorder.localnet.mda.or.jp>
parents:
86
diff
changeset
|
74 exec( $cmdline ); |
3bed74eca373
change: EPG取得並列化が可能かどうかを判定するように変更
epgrec@park.mda.or.jp <yoneda@recorder.localnet.mda.or.jp>
parents:
86
diff
changeset
|
75 } |
3bed74eca373
change: EPG取得並列化が可能かどうかを判定するように変更
epgrec@park.mda.or.jp <yoneda@recorder.localnet.mda.or.jp>
parents:
86
diff
changeset
|
76 else { |
3bed74eca373
change: EPG取得並列化が可能かどうかを判定するように変更
epgrec@park.mda.or.jp <yoneda@recorder.localnet.mda.or.jp>
parents:
86
diff
changeset
|
77 storeProgram( "CS", $temp_xml_cs1 ); |
3bed74eca373
change: EPG取得並列化が可能かどうかを判定するように変更
epgrec@park.mda.or.jp <yoneda@recorder.localnet.mda.or.jp>
parents:
86
diff
changeset
|
78 if( file_exists( $temp_xml_cs1 ) ) @unlink( $temp_xml_cs1 ); |
3bed74eca373
change: EPG取得並列化が可能かどうかを判定するように変更
epgrec@park.mda.or.jp <yoneda@recorder.localnet.mda.or.jp>
parents:
86
diff
changeset
|
79 } |
67
a2c4665b310c
add: CS support (thanks to dakku)
Sushi-k <epgrec@park.mda.or.jp>
parents:
64
diff
changeset
|
80 if( file_exists( $settings->temp_data ) ) @unlink( $settings->temp_data ); |
82
330c83ae8c95
fix: CSのEPG取得時に予約重複チェックを行っていなかったのを修正
yoneda <yoneda@recorder.localnet.mda.or.jp>
parents:
70
diff
changeset
|
81 } |
330c83ae8c95
fix: CSのEPG取得時に予約重複チェックを行っていなかったのを修正
yoneda <yoneda@recorder.localnet.mda.or.jp>
parents:
70
diff
changeset
|
82 $num = DBRecord::countRecords( RESERVE_TBL, "WHERE complete = '0' AND (type = 'BS' OR type = 'CS') AND endtime > now() AND starttime < addtime( now(), '00:03:05')" ); |
85 | 83 if( ($num == 0) && check_file($temp_xml_cs2) ) { |
84 $cmdline = "CHANNEL=".CS2_EPG_CHANNEL." DURATION=120 TYPE=CS TUNER=0 MODE=0 OUTPUT=".$settings->temp_data." ".DO_RECORD . " >/dev/null 2>&1"; | |
67
a2c4665b310c
add: CS support (thanks to dakku)
Sushi-k <epgrec@park.mda.or.jp>
parents:
64
diff
changeset
|
85 exec( $cmdline ); |
85 | 86 $cmdline = $settings->epgdump." /CS ".$settings->temp_data." ".$temp_xml_cs2; |
67
a2c4665b310c
add: CS support (thanks to dakku)
Sushi-k <epgrec@park.mda.or.jp>
parents:
64
diff
changeset
|
87 exec( $cmdline ); |
111
3bed74eca373
change: EPG取得並列化が可能かどうかを判定するように変更
epgrec@park.mda.or.jp <yoneda@recorder.localnet.mda.or.jp>
parents:
86
diff
changeset
|
88 if( $use_para ) { |
3bed74eca373
change: EPG取得並列化が可能かどうかを判定するように変更
epgrec@park.mda.or.jp <yoneda@recorder.localnet.mda.or.jp>
parents:
86
diff
changeset
|
89 $cmdline = INSTALL_PATH."/storeProgram.php CS ".$temp_xml_cs2." >/dev/null 2>&1 &"; |
3bed74eca373
change: EPG取得並列化が可能かどうかを判定するように変更
epgrec@park.mda.or.jp <yoneda@recorder.localnet.mda.or.jp>
parents:
86
diff
changeset
|
90 exec( $cmdline ); |
3bed74eca373
change: EPG取得並列化が可能かどうかを判定するように変更
epgrec@park.mda.or.jp <yoneda@recorder.localnet.mda.or.jp>
parents:
86
diff
changeset
|
91 } |
3bed74eca373
change: EPG取得並列化が可能かどうかを判定するように変更
epgrec@park.mda.or.jp <yoneda@recorder.localnet.mda.or.jp>
parents:
86
diff
changeset
|
92 else { |
3bed74eca373
change: EPG取得並列化が可能かどうかを判定するように変更
epgrec@park.mda.or.jp <yoneda@recorder.localnet.mda.or.jp>
parents:
86
diff
changeset
|
93 storeProgram( "CS", $temp_xml_cs2 ); |
3bed74eca373
change: EPG取得並列化が可能かどうかを判定するように変更
epgrec@park.mda.or.jp <yoneda@recorder.localnet.mda.or.jp>
parents:
86
diff
changeset
|
94 if( file_exists( $temp_xml_cs2 ) ) @unlink( $temp_xml_cs2 ); |
3bed74eca373
change: EPG取得並列化が可能かどうかを判定するように変更
epgrec@park.mda.or.jp <yoneda@recorder.localnet.mda.or.jp>
parents:
86
diff
changeset
|
95 } |
67
a2c4665b310c
add: CS support (thanks to dakku)
Sushi-k <epgrec@park.mda.or.jp>
parents:
64
diff
changeset
|
96 if( file_exists( $settings->temp_data ) ) @unlink( $settings->temp_data ); |
a2c4665b310c
add: CS support (thanks to dakku)
Sushi-k <epgrec@park.mda.or.jp>
parents:
64
diff
changeset
|
97 } |
1 | 98 } |
99 } | |
100 | |
101 // 遺羈≪ | |
57 | 102 if( $settings->gr_tuners != 0 ) { |
1 | 103 foreach( $GR_CHANNEL_MAP as $key=>$value ){ |
104 // 牙脂茲с | |
37
e5f9aa34d06f
change: modify all script for web base setting
yoneda <epgrec@park.mda.or.jp>
parents:
7
diff
changeset
|
105 $num = DBRecord::countRecords( RESERVE_TBL, "WHERE complete = '0' AND type = 'GR' AND endtime > now() AND starttime < addtime( now(), '00:01:10')" ); |
85 | 106 if( ($num == 0) && check_file($temp_xml_gr.$value."") ) { |
37
e5f9aa34d06f
change: modify all script for web base setting
yoneda <epgrec@park.mda.or.jp>
parents:
7
diff
changeset
|
107 $cmdline = "CHANNEL=".$value." DURATION=60 TYPE=GR TUNER=0 MODE=0 OUTPUT=".$settings->temp_data." ".DO_RECORD . " >/dev/null 2>&1"; |
1 | 108 exec( $cmdline ); |
85 | 109 $cmdline = $settings->epgdump." ".$key." ".$settings->temp_data." ".$temp_xml_gr.$value.""; |
1 | 110 exec( $cmdline ); |
111
3bed74eca373
change: EPG取得並列化が可能かどうかを判定するように変更
epgrec@park.mda.or.jp <yoneda@recorder.localnet.mda.or.jp>
parents:
86
diff
changeset
|
111 if( $use_para ) { |
3bed74eca373
change: EPG取得並列化が可能かどうかを判定するように変更
epgrec@park.mda.or.jp <yoneda@recorder.localnet.mda.or.jp>
parents:
86
diff
changeset
|
112 $cmdline = INSTALL_PATH."/storeProgram.php GR ".$temp_xml_gr.$value." >/dev/null 2>&1 &"; |
3bed74eca373
change: EPG取得並列化が可能かどうかを判定するように変更
epgrec@park.mda.or.jp <yoneda@recorder.localnet.mda.or.jp>
parents:
86
diff
changeset
|
113 exec( $cmdline ); |
3bed74eca373
change: EPG取得並列化が可能かどうかを判定するように変更
epgrec@park.mda.or.jp <yoneda@recorder.localnet.mda.or.jp>
parents:
86
diff
changeset
|
114 } |
3bed74eca373
change: EPG取得並列化が可能かどうかを判定するように変更
epgrec@park.mda.or.jp <yoneda@recorder.localnet.mda.or.jp>
parents:
86
diff
changeset
|
115 else { |
3bed74eca373
change: EPG取得並列化が可能かどうかを判定するように変更
epgrec@park.mda.or.jp <yoneda@recorder.localnet.mda.or.jp>
parents:
86
diff
changeset
|
116 storeProgram( "GR", $temp_xml_gr.$value ); |
3bed74eca373
change: EPG取得並列化が可能かどうかを判定するように変更
epgrec@park.mda.or.jp <yoneda@recorder.localnet.mda.or.jp>
parents:
86
diff
changeset
|
117 if( file_exists( $temp_xml_gr.$value ) ) @unlink( $temp_xml_gr.$value ); |
3bed74eca373
change: EPG取得並列化が可能かどうかを判定するように変更
epgrec@park.mda.or.jp <yoneda@recorder.localnet.mda.or.jp>
parents:
86
diff
changeset
|
118 } |
84
3ec5ca5e56ca
add: EPG取得並列化版を暫定的に標準に
yoneda <yoneda@recorder.localnet.mda.or.jp>
parents:
82
diff
changeset
|
119 if( file_exists( $settings->temp_data ) ) @unlink( $settings->temp_data ); |
1 | 120 } |
121 } | |
122 } | |
111
3bed74eca373
change: EPG取得並列化が可能かどうかを判定するように変更
epgrec@park.mda.or.jp <yoneda@recorder.localnet.mda.or.jp>
parents:
86
diff
changeset
|
123 // 筝х |
3bed74eca373
change: EPG取得並列化が可能かどうかを判定するように変更
epgrec@park.mda.or.jp <yoneda@recorder.localnet.mda.or.jp>
parents:
86
diff
changeset
|
124 if( $use_para ) exit(); |
1 | 125 |
111
3bed74eca373
change: EPG取得並列化が可能かどうかを判定するように変更
epgrec@park.mda.or.jp <yoneda@recorder.localnet.mda.or.jp>
parents:
86
diff
changeset
|
126 garbageClean(); // 筝荀違 |
3bed74eca373
change: EPG取得並列化が可能かどうかを判定するように変更
epgrec@park.mda.or.jp <yoneda@recorder.localnet.mda.or.jp>
parents:
86
diff
changeset
|
127 doKeywordReservation(); // 若若篋膣 |
3bed74eca373
change: EPG取得並列化が可能かどうかを判定するように変更
epgrec@park.mda.or.jp <yoneda@recorder.localnet.mda.or.jp>
parents:
86
diff
changeset
|
128 exit(); |
84
3ec5ca5e56ca
add: EPG取得並列化版を暫定的に標準に
yoneda <yoneda@recorder.localnet.mda.or.jp>
parents:
82
diff
changeset
|
129 ?> |