Mercurial > epgrec.yaz
annotate Reservation.class.php @ 150:3a6ec345ab0c
merged with upstream
author | Yoshiki Yazawa <yaz@honeyplanet.jp> |
---|---|
date | Sat, 27 Mar 2010 23:21:25 +0900 |
parents | 4afd353b4507 5b192e94f49d |
children | 66eabfc1b118 |
rev | line source |
---|---|
1 | 1 <?php |
2 include_once('config.php'); | |
3 include_once( INSTALL_PATH . "/DBRecord.class.php" ); | |
4 include_once( INSTALL_PATH . "/reclib.php" ); | |
39
8965ef108821
change: modify all scripts for web base setting.
Sushi-k <epgrec@park.mda.or.jp>
parents:
15
diff
changeset
|
5 include_once( INSTALL_PATH . "/Settings.class.php" ); |
135
9c5e597ef6c6
mod: ログ機能を追加
epgrec@park.mda.or.jp <yoneda@recorder.localnet.mda.or.jp>
parents:
134
diff
changeset
|
6 include_once( INSTALL_PATH . "/recLog.inc.php" ); |
39
8965ef108821
change: modify all scripts for web base setting.
Sushi-k <epgrec@park.mda.or.jp>
parents:
15
diff
changeset
|
7 |
1 | 8 |
9 // 篋膣 | |
10 | |
11 class Reservation { | |
75
11f63ae04a96
delete trailing white space
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
71
diff
changeset
|
12 |
1 | 13 public static function simple( $program_id , $autorec = 0, $mode = 0) { |
39
8965ef108821
change: modify all scripts for web base setting.
Sushi-k <epgrec@park.mda.or.jp>
parents:
15
diff
changeset
|
14 $settings = Settings::factory(); |
1 | 15 $rval = 0; |
16 try { | |
39
8965ef108821
change: modify all scripts for web base setting.
Sushi-k <epgrec@park.mda.or.jp>
parents:
15
diff
changeset
|
17 $prec = new DBRecord( PROGRAM_TBL, "id", $program_id ); |
75
11f63ae04a96
delete trailing white space
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
71
diff
changeset
|
18 |
1 | 19 $rval = self::custom( |
20 $prec->starttime, | |
21 $prec->endtime, | |
22 $prec->channel_id, | |
23 $prec->title, | |
24 $prec->description, | |
25 $prec->category_id, | |
26 $program_id, | |
27 $autorec, | |
28 $mode ); | |
75
11f63ae04a96
delete trailing white space
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
71
diff
changeset
|
29 |
1 | 30 } |
31 catch( Exception $e ) { | |
32 throw $e; | |
33 } | |
34 return $rval; | |
35 } | |
75
11f63ae04a96
delete trailing white space
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
71
diff
changeset
|
36 |
1 | 37 public static function custom( |
38 $starttime, // 紮Datetime | |
39 $endtime, // 腟篋Datetime | |
40 $channel_id, // c潟ID | |
41 $title = "none", // 帥ゃ | |
42 $description = "none", // 网荀 | |
43 $category_id = 0, // 眼ID | |
44 $program_id = 0, // 腟ID | |
45 $autorec = 0, // 牙 | |
142
481e789605e3
mod: EPGの更新と同時に予約情報を更新するように変更、ログビューアの追加
epgrec@park.mda.or.jp <yoneda@recorder.localnet.mda.or.jp>
parents:
135
diff
changeset
|
46 $mode = 0, // 牙祉≪若 |
481e789605e3
mod: EPGの更新と同時に予約情報を更新するように変更、ログビューアの追加
epgrec@park.mda.or.jp <yoneda@recorder.localnet.mda.or.jp>
parents:
135
diff
changeset
|
47 $dirty = 0 // 若c |
1 | 48 ) { |
49 global $RECORD_MODE; | |
39
8965ef108821
change: modify all scripts for web base setting.
Sushi-k <epgrec@park.mda.or.jp>
parents:
15
diff
changeset
|
50 $settings = Settings::factory(); |
8965ef108821
change: modify all scripts for web base setting.
Sushi-k <epgrec@park.mda.or.jp>
parents:
15
diff
changeset
|
51 |
1 | 52 // 荐膊 |
53 $start_time = toTimestamp( $starttime ); | |
39
8965ef108821
change: modify all scripts for web base setting.
Sushi-k <epgrec@park.mda.or.jp>
parents:
15
diff
changeset
|
54 $end_time = toTimestamp( $endtime ) + $settings->extra_time; |
75
11f63ae04a96
delete trailing white space
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
71
diff
changeset
|
55 |
1 | 56 if( $start_time < (time() + PADDING_TIME + 10) ) { // 憜祉3絨鐚с紮腟 |
57 $start_time = time() + PADDING_TIME + 10; // 牙脂紮310腱荐絎 | |
58 } | |
59 $at_start = $start_time - PADDING_TIME; | |
39
8965ef108821
change: modify all scripts for web base setting.
Sushi-k <epgrec@park.mda.or.jp>
parents:
15
diff
changeset
|
60 $sleep_time = PADDING_TIME - $settings->former_time; |
8965ef108821
change: modify all scripts for web base setting.
Sushi-k <epgrec@park.mda.or.jp>
parents:
15
diff
changeset
|
61 $rec_start = $start_time - $settings->former_time; |
75
11f63ae04a96
delete trailing white space
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
71
diff
changeset
|
62 |
1 | 63 // duration荐膊 |
64 $duration = $end_time - $rec_start; | |
39
8965ef108821
change: modify all scripts for web base setting.
Sushi-k <epgrec@park.mda.or.jp>
parents:
15
diff
changeset
|
65 if( $duration < ($settings->former_time + 60) ) { // 60腱篁ヤ腟綣障 |
1 | 66 throw new Exception( "腟ゃゃ/腟c腟с" ); |
67 } | |
75
11f63ae04a96
delete trailing white space
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
71
diff
changeset
|
68 |
1 | 69 $rrec = null; |
70 try { | |
71 // 筝腟篋膣с | |
72 if( $program_id ) { | |
39
8965ef108821
change: modify all scripts for web base setting.
Sushi-k <epgrec@park.mda.or.jp>
parents:
15
diff
changeset
|
73 $num = DBRecord::countRecords( RESERVE_TBL, "WHERE program_id = '".$program_id."'" ); |
1 | 74 if( $num ) { |
75 throw new Exception("筝腟牙私膣障"); | |
76 } | |
77 } | |
75
11f63ae04a96
delete trailing white space
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
71
diff
changeset
|
78 |
39
8965ef108821
change: modify all scripts for web base setting.
Sushi-k <epgrec@park.mda.or.jp>
parents:
15
diff
changeset
|
79 $crec = new DBRecord( CHANNEL_TBL, "id", $channel_id ); |
75
11f63ae04a96
delete trailing white space
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
71
diff
changeset
|
80 |
1 | 81 // √篋膣 = TUNER |
120 | 82 $tuners = ($crec->type == "GR") ? (int)($settings->gr_tuners) : (int)($settings->bs_tuners); |
91
f6b909678e51
fix: CSとBSを合計するとチューナー数以上の重複予約が出来てしまうバグを修正
Sushi-k <epgrec@park.mda.or.jp>
parents:
79
diff
changeset
|
83 $type_str = ($crec->type == "GR") ? "type = 'GR' " : "(type = 'BS' OR type = 'CS') "; |
102
49145003e6a3
fix whitespace and new line code
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
92
diff
changeset
|
84 |
39
8965ef108821
change: modify all scripts for web base setting.
Sushi-k <epgrec@park.mda.or.jp>
parents:
15
diff
changeset
|
85 $battings = DBRecord::countRecords( RESERVE_TBL, "WHERE complete = '0' ". |
91
f6b909678e51
fix: CSとBSを合計するとチューナー数以上の重複予約が出来てしまうバグを修正
Sushi-k <epgrec@park.mda.or.jp>
parents:
79
diff
changeset
|
86 "AND ".$type_str. |
39
8965ef108821
change: modify all scripts for web base setting.
Sushi-k <epgrec@park.mda.or.jp>
parents:
15
diff
changeset
|
87 "AND starttime < '".toDatetime($end_time) ."' ". |
8965ef108821
change: modify all scripts for web base setting.
Sushi-k <epgrec@park.mda.or.jp>
parents:
15
diff
changeset
|
88 "AND endtime > '".toDatetime($rec_start)."'" |
1 | 89 ); |
75
11f63ae04a96
delete trailing white space
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
71
diff
changeset
|
90 |
1 | 91 if( $battings >= $tuners ) { |
92 // 茲肴 | |
40 | 93 if( $settings->force_cont_rec == 1 ) { |
1 | 94 // 茹f純茲茯帥鴻 |
95 // 緇篋膣 | |
39
8965ef108821
change: modify all scripts for web base setting.
Sushi-k <epgrec@park.mda.or.jp>
parents:
15
diff
changeset
|
96 $nexts = DBRecord::countRecords( RESERVE_TBL, "WHERE complete = '0' ". |
91
f6b909678e51
fix: CSとBSを合計するとチューナー数以上の重複予約が出来てしまうバグを修正
Sushi-k <epgrec@park.mda.or.jp>
parents:
79
diff
changeset
|
97 "AND ".$type_str. |
39
8965ef108821
change: modify all scripts for web base setting.
Sushi-k <epgrec@park.mda.or.jp>
parents:
15
diff
changeset
|
98 "AND starttime = '".toDatetime($end_time - $settings->former_time)."'"); |
75
11f63ae04a96
delete trailing white space
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
71
diff
changeset
|
99 |
39
8965ef108821
change: modify all scripts for web base setting.
Sushi-k <epgrec@park.mda.or.jp>
parents:
15
diff
changeset
|
100 $prevs = DBRecord::countRecords( RESERVE_TBL, "WHERE complete = '0' ". |
91
f6b909678e51
fix: CSとBSを合計するとチューナー数以上の重複予約が出来てしまうバグを修正
Sushi-k <epgrec@park.mda.or.jp>
parents:
79
diff
changeset
|
101 "AND ".$type_str. |
39
8965ef108821
change: modify all scripts for web base setting.
Sushi-k <epgrec@park.mda.or.jp>
parents:
15
diff
changeset
|
102 "AND endtime = '".$starttime."'" ); |
75
11f63ae04a96
delete trailing white space
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
71
diff
changeset
|
103 |
1 | 104 // 緇綣ャ若惹違遺札筝茲茹f∞ |
105 if( ($battings - $nexts - $prevs) >= $tuners ) | |
106 throw new Exception( "茲篋膣茹fс障" ); | |
75
11f63ae04a96
delete trailing white space
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
71
diff
changeset
|
107 |
1 | 108 // 翫腟? |
109 if( $nexts ) { | |
110 // 腟腟<c | |
39
8965ef108821
change: modify all scripts for web base setting.
Sushi-k <epgrec@park.mda.or.jp>
parents:
15
diff
changeset
|
111 $end_time = $end_time - $settings->former_time - $settings->rec_switch_time; |
1 | 112 $duration = $end_time - $rec_start; // duration荐膊 |
113 } | |
114 $battings -= $nexts; | |
75
11f63ae04a96
delete trailing white space
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
71
diff
changeset
|
115 |
1 | 116 // 翫牙私膣荀篁 |
39
8965ef108821
change: modify all scripts for web base setting.
Sushi-k <epgrec@park.mda.or.jp>
parents:
15
diff
changeset
|
117 $trecs = DBRecord::createRecords(RESERVE_TBL, "WHERE complete = '0' ". |
91
f6b909678e51
fix: CSとBSを合計するとチューナー数以上の重複予約が出来てしまうバグを修正
Sushi-k <epgrec@park.mda.or.jp>
parents:
79
diff
changeset
|
118 "AND ".$type_str. |
39
8965ef108821
change: modify all scripts for web base setting.
Sushi-k <epgrec@park.mda.or.jp>
parents:
15
diff
changeset
|
119 "AND endtime = '".$starttime."'" ); |
1 | 120 // 翫腟 |
121 for( $i = 0; $i < count($trecs) ; $i++ ) { | |
122 if( $battings < $tuners ) break; // 茹f腟篋? | |
123 // 篋膣篆罩c綽荀宴冴 | |
124 $prev_id = $trecs[$i]->id; | |
125 $prev_program_id = $trecs[$i]->program_id; | |
126 $prev_channel_id = $trecs[$i]->channel_id; | |
127 $prev_title = $trecs[$i]->title; | |
128 $prev_description = $trecs[$i]->description; | |
129 $prev_category_id = $trecs[$i]->category_id; | |
130 $prev_starttime = $trecs[$i]->starttime; | |
131 $prev_endtime = $trecs[$i]->endtime; | |
132 $prev_autorec = $trecs[$i]->autorec; | |
133 $prev_mode = $trecs[$i]->mode; | |
142
481e789605e3
mod: EPGの更新と同時に予約情報を更新するように変更、ログビューアの追加
epgrec@park.mda.or.jp <yoneda@recorder.localnet.mda.or.jp>
parents:
135
diff
changeset
|
134 $prev_dirty = $trecs[$i]->dirty; |
1 | 135 |
136 $prev_start_time = toTimestamp($prev_starttime); | |
137 // 紮障c篋膣鐚 | |
39
8965ef108821
change: modify all scripts for web base setting.
Sushi-k <epgrec@park.mda.or.jp>
parents:
15
diff
changeset
|
138 if( $prev_start_time > (time() + PADDING_TIME + $settings->former_time) ) { |
1 | 139 // 紮祉祉 |
39
8965ef108821
change: modify all scripts for web base setting.
Sushi-k <epgrec@park.mda.or.jp>
parents:
15
diff
changeset
|
140 $prev_starttime = toDatetime( $prev_start_time + $settings->former_time ); |
1 | 141 // 腟<c |
39
8965ef108821
change: modify all scripts for web base setting.
Sushi-k <epgrec@park.mda.or.jp>
parents:
15
diff
changeset
|
142 $prev_endtime = toDatetime( toTimestamp($prev_endtime) - $settings->former_time - $settings->rec_switch_time ); |
75
11f63ae04a96
delete trailing white space
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
71
diff
changeset
|
143 |
1 | 144 // try鴻 |
145 try { | |
146 // c篋膣羔 | |
147 self::cancel( $prev_id ); | |
148 // 篋膣 | |
75
11f63ae04a96
delete trailing white space
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
71
diff
changeset
|
149 self::custom( |
1 | 150 $prev_starttime, // 紮Datetime |
151 $prev_endtime, // 腟篋Datetime | |
152 $prev_channel_id, // c潟ID | |
153 $prev_title, // 帥ゃ | |
154 $prev_description, // 网荀 | |
155 $prev_category_id, // 眼ID | |
156 $prev_program_id, // 腟ID | |
157 $prev_autorec, // 牙 | |
142
481e789605e3
mod: EPGの更新と同時に予約情報を更新するように変更、ログビューアの追加
epgrec@park.mda.or.jp <yoneda@recorder.localnet.mda.or.jp>
parents:
135
diff
changeset
|
158 $prev_mode, |
481e789605e3
mod: EPGの更新と同時に予約情報を更新するように変更、ログビューアの追加
epgrec@park.mda.or.jp <yoneda@recorder.localnet.mda.or.jp>
parents:
135
diff
changeset
|
159 $prev_dirty ); |
1 | 160 } |
161 catch( Exception $e ) { | |
162 throw new Exception( "茲篋膣茹fс障" ); | |
163 } | |
164 } | |
165 else { | |
166 throw new Exception( "茲篋膣茹fс障" ); | |
167 } | |
168 $battings--; | |
169 } | |
170 if( $battings < 0 ) $battings = 0; | |
171 // ч茲茹f | |
172 } | |
173 else { | |
174 throw new Exception( "茲篋膣障" ); | |
175 } | |
176 } | |
177 // ャ若主 | |
178 $tuner = $battings; | |
75
11f63ae04a96
delete trailing white space
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
71
diff
changeset
|
179 |
1 | 180 // 鴻durationс |
39
8965ef108821
change: modify all scripts for web base setting.
Sushi-k <epgrec@park.mda.or.jp>
parents:
15
diff
changeset
|
181 if( $duration < ($settings->former_time + 60) ) { // 60腱篁ヤ腟綣障 |
1 | 182 throw new Exception( "腟ゃゃ/腟c腟с" ); |
183 } | |
184 | |
15
cbbddf99d1cd
added: filename customize function
Sushi-k <epgrec@park.mda.or.jp>
parents:
8
diff
changeset
|
185 // <ゃ |
cbbddf99d1cd
added: filename customize function
Sushi-k <epgrec@park.mda.or.jp>
parents:
8
diff
changeset
|
186 /* |
cbbddf99d1cd
added: filename customize function
Sushi-k <epgrec@park.mda.or.jp>
parents:
8
diff
changeset
|
187 %TITLE% 腟帥ゃ |
cbbddf99d1cd
added: filename customize function
Sushi-k <epgrec@park.mda.or.jp>
parents:
8
diff
changeset
|
188 %ST% 紮ユ鐚ex.200907201830) |
cbbddf99d1cd
added: filename customize function
Sushi-k <epgrec@park.mda.or.jp>
parents:
8
diff
changeset
|
189 %ET% 腟篋ユ |
91
f6b909678e51
fix: CSとBSを合計するとチューナー数以上の重複予約が出来てしまうバグを修正
Sushi-k <epgrec@park.mda.or.jp>
parents:
79
diff
changeset
|
190 %TYPE% GR/BS/CS |
15
cbbddf99d1cd
added: filename customize function
Sushi-k <epgrec@park.mda.or.jp>
parents:
8
diff
changeset
|
191 %CH% c潟 |
cbbddf99d1cd
added: filename customize function
Sushi-k <epgrec@park.mda.or.jp>
parents:
8
diff
changeset
|
192 %DOW% ワSun-Mon鐚 |
cbbddf99d1cd
added: filename customize function
Sushi-k <epgrec@park.mda.or.jp>
parents:
8
diff
changeset
|
193 %DOWJ% ワ-鐚 |
cbbddf99d1cd
added: filename customize function
Sushi-k <epgrec@park.mda.or.jp>
parents:
8
diff
changeset
|
194 %YEAR% 紮綛 |
cbbddf99d1cd
added: filename customize function
Sushi-k <epgrec@park.mda.or.jp>
parents:
8
diff
changeset
|
195 %MONTH% 紮 |
cbbddf99d1cd
added: filename customize function
Sushi-k <epgrec@park.mda.or.jp>
parents:
8
diff
changeset
|
196 %DAY% 紮 |
cbbddf99d1cd
added: filename customize function
Sushi-k <epgrec@park.mda.or.jp>
parents:
8
diff
changeset
|
197 %HOUR% 紮 |
cbbddf99d1cd
added: filename customize function
Sushi-k <epgrec@park.mda.or.jp>
parents:
8
diff
changeset
|
198 %MIN% 紮 |
cbbddf99d1cd
added: filename customize function
Sushi-k <epgrec@park.mda.or.jp>
parents:
8
diff
changeset
|
199 %SEC% 紮腱 |
cbbddf99d1cd
added: filename customize function
Sushi-k <epgrec@park.mda.or.jp>
parents:
8
diff
changeset
|
200 %DURATION% 牙紙鐚腱鐚 |
cbbddf99d1cd
added: filename customize function
Sushi-k <epgrec@park.mda.or.jp>
parents:
8
diff
changeset
|
201 */ |
cbbddf99d1cd
added: filename customize function
Sushi-k <epgrec@park.mda.or.jp>
parents:
8
diff
changeset
|
202 |
cbbddf99d1cd
added: filename customize function
Sushi-k <epgrec@park.mda.or.jp>
parents:
8
diff
changeset
|
203 $day_of_week = array( "","","","羂","","","" ); |
39
8965ef108821
change: modify all scripts for web base setting.
Sushi-k <epgrec@park.mda.or.jp>
parents:
15
diff
changeset
|
204 $filename = $settings->filename_format; |
8965ef108821
change: modify all scripts for web base setting.
Sushi-k <epgrec@park.mda.or.jp>
parents:
15
diff
changeset
|
205 |
116
f268d7d10590
fix: マルチバイトmb_str_replaceをネットからいただいて追加
yoneda <epgrec@park.mda.or.jp>
parents:
91
diff
changeset
|
206 // %TITLE% |
133 | 207 $filename = mb_str_replace("%TITLE%", trim($title), $filename); |
116
f268d7d10590
fix: マルチバイトmb_str_replaceをネットからいただいて追加
yoneda <epgrec@park.mda.or.jp>
parents:
91
diff
changeset
|
208 // %ST% 紮ユ |
f268d7d10590
fix: マルチバイトmb_str_replaceをネットからいただいて追加
yoneda <epgrec@park.mda.or.jp>
parents:
91
diff
changeset
|
209 $filename = mb_str_replace("%ST%",date("YmdHis", $start_time), $filename ); |
f268d7d10590
fix: マルチバイトmb_str_replaceをネットからいただいて追加
yoneda <epgrec@park.mda.or.jp>
parents:
91
diff
changeset
|
210 // %ET% 腟篋ユ |
f268d7d10590
fix: マルチバイトmb_str_replaceをネットからいただいて追加
yoneda <epgrec@park.mda.or.jp>
parents:
91
diff
changeset
|
211 $filename = mb_str_replace("%ET%",date("YmdHis", $end_time), $filename ); |
f268d7d10590
fix: マルチバイトmb_str_replaceをネットからいただいて追加
yoneda <epgrec@park.mda.or.jp>
parents:
91
diff
changeset
|
212 // %TYPE% GR/BS |
f268d7d10590
fix: マルチバイトmb_str_replaceをネットからいただいて追加
yoneda <epgrec@park.mda.or.jp>
parents:
91
diff
changeset
|
213 $filename = mb_str_replace("%TYPE%",$crec->type, $filename ); |
f268d7d10590
fix: マルチバイトmb_str_replaceをネットからいただいて追加
yoneda <epgrec@park.mda.or.jp>
parents:
91
diff
changeset
|
214 // %CH% c潟 |
f268d7d10590
fix: マルチバイトmb_str_replaceをネットからいただいて追加
yoneda <epgrec@park.mda.or.jp>
parents:
91
diff
changeset
|
215 $filename = mb_str_replace("%CH%","".$crec->channel, $filename ); |
f268d7d10590
fix: マルチバイトmb_str_replaceをネットからいただいて追加
yoneda <epgrec@park.mda.or.jp>
parents:
91
diff
changeset
|
216 // %DOW% ワSun-Mon鐚 |
f268d7d10590
fix: マルチバイトmb_str_replaceをネットからいただいて追加
yoneda <epgrec@park.mda.or.jp>
parents:
91
diff
changeset
|
217 $filename = mb_str_replace("%DOW%",date("D", $start_time), $filename ); |
f268d7d10590
fix: マルチバイトmb_str_replaceをネットからいただいて追加
yoneda <epgrec@park.mda.or.jp>
parents:
91
diff
changeset
|
218 // %DOWJ% ワ-鐚 |
f268d7d10590
fix: マルチバイトmb_str_replaceをネットからいただいて追加
yoneda <epgrec@park.mda.or.jp>
parents:
91
diff
changeset
|
219 $filename = mb_str_replace("%DOWJ%",$day_of_week[(int)date("w", $start_time)], $filename ); |
f268d7d10590
fix: マルチバイトmb_str_replaceをネットからいただいて追加
yoneda <epgrec@park.mda.or.jp>
parents:
91
diff
changeset
|
220 // %YEAR% 紮綛 |
f268d7d10590
fix: マルチバイトmb_str_replaceをネットからいただいて追加
yoneda <epgrec@park.mda.or.jp>
parents:
91
diff
changeset
|
221 $filename = mb_str_replace("%YEAR%",date("Y", $start_time), $filename ); |
f268d7d10590
fix: マルチバイトmb_str_replaceをネットからいただいて追加
yoneda <epgrec@park.mda.or.jp>
parents:
91
diff
changeset
|
222 // %MONTH% 紮 |
f268d7d10590
fix: マルチバイトmb_str_replaceをネットからいただいて追加
yoneda <epgrec@park.mda.or.jp>
parents:
91
diff
changeset
|
223 $filename = mb_str_replace("%MONTH%",date("m", $start_time), $filename ); |
f268d7d10590
fix: マルチバイトmb_str_replaceをネットからいただいて追加
yoneda <epgrec@park.mda.or.jp>
parents:
91
diff
changeset
|
224 // %DAY% 紮 |
f268d7d10590
fix: マルチバイトmb_str_replaceをネットからいただいて追加
yoneda <epgrec@park.mda.or.jp>
parents:
91
diff
changeset
|
225 $filename = mb_str_replace("%DAY%",date("d", $start_time), $filename ); |
f268d7d10590
fix: マルチバイトmb_str_replaceをネットからいただいて追加
yoneda <epgrec@park.mda.or.jp>
parents:
91
diff
changeset
|
226 // %HOUR% 紮 |
f268d7d10590
fix: マルチバイトmb_str_replaceをネットからいただいて追加
yoneda <epgrec@park.mda.or.jp>
parents:
91
diff
changeset
|
227 $filename = mb_str_replace("%HOUR%",date("H", $start_time), $filename ); |
f268d7d10590
fix: マルチバイトmb_str_replaceをネットからいただいて追加
yoneda <epgrec@park.mda.or.jp>
parents:
91
diff
changeset
|
228 // %MIN% 紮 |
f268d7d10590
fix: マルチバイトmb_str_replaceをネットからいただいて追加
yoneda <epgrec@park.mda.or.jp>
parents:
91
diff
changeset
|
229 $filename = mb_str_replace("%MIN%",date("i", $start_time), $filename ); |
f268d7d10590
fix: マルチバイトmb_str_replaceをネットからいただいて追加
yoneda <epgrec@park.mda.or.jp>
parents:
91
diff
changeset
|
230 // %SEC% 紮腱 |
f268d7d10590
fix: マルチバイトmb_str_replaceをネットからいただいて追加
yoneda <epgrec@park.mda.or.jp>
parents:
91
diff
changeset
|
231 $filename = mb_str_replace("%SEC%",date("s", $start_time), $filename ); |
f268d7d10590
fix: マルチバイトmb_str_replaceをネットからいただいて追加
yoneda <epgrec@park.mda.or.jp>
parents:
91
diff
changeset
|
232 // %DURATION% 牙紙鐚腱鐚 |
f268d7d10590
fix: マルチバイトmb_str_replaceをネットからいただいて追加
yoneda <epgrec@park.mda.or.jp>
parents:
91
diff
changeset
|
233 $filename = mb_str_replace("%DURATION%","".$duration, $filename ); |
f268d7d10590
fix: マルチバイトmb_str_replaceをネットからいただいて追加
yoneda <epgrec@park.mda.or.jp>
parents:
91
diff
changeset
|
234 |
133 | 235 // √絖_ |
134
58791b90221b
mod: mb_ereg_replace -> preg_replace
yoneda <epgrec@park.mda.or.jp>
parents:
133
diff
changeset
|
236 $filename = preg_replace("/[ \.\/\*:<>\?\\|()\'\"&]/u","_", trim($filename) ); |
133 | 237 |
15
cbbddf99d1cd
added: filename customize function
Sushi-k <epgrec@park.mda.or.jp>
parents:
8
diff
changeset
|
238 // 絖潟若紊 |
76
69e0dabc765a
fixed: Reservation.class.php
Sushi-k <epgrec@park.mda.or.jp>
parents:
56
diff
changeset
|
239 if( defined("FILESYSTEM_ENCODING") ) { |
15
cbbddf99d1cd
added: filename customize function
Sushi-k <epgrec@park.mda.or.jp>
parents:
8
diff
changeset
|
240 $filename = mb_convert_encoding( $filename, FILESYSTEM_ENCODING, "UTF-8" ); |
cbbddf99d1cd
added: filename customize function
Sushi-k <epgrec@park.mda.or.jp>
parents:
8
diff
changeset
|
241 } |
133 | 242 |
76
69e0dabc765a
fixed: Reservation.class.php
Sushi-k <epgrec@park.mda.or.jp>
parents:
56
diff
changeset
|
243 $filename .= $RECORD_MODE["$mode"]['suffix']; |
47 | 244 $thumbname = $filename.".jpg"; |
75
11f63ae04a96
delete trailing white space
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
71
diff
changeset
|
245 |
56
be9e4520cfec
change: GEN_THUMBNAIL
yoneda <yoneda@recorder.localnet.mda.or.jp>
parents:
48
diff
changeset
|
246 // 泣若 |
be9e4520cfec
change: GEN_THUMBNAIL
yoneda <yoneda@recorder.localnet.mda.or.jp>
parents:
48
diff
changeset
|
247 $gen_thumbnail = INSTALL_PATH."/gen-thumbnail.sh"; |
75
11f63ae04a96
delete trailing white space
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
71
diff
changeset
|
248 if( defined("GEN_THUMBNAIL") ) |
56
be9e4520cfec
change: GEN_THUMBNAIL
yoneda <yoneda@recorder.localnet.mda.or.jp>
parents:
48
diff
changeset
|
249 $gen_thumbnail = GEN_THUMBNAIL; |
75
11f63ae04a96
delete trailing white space
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
71
diff
changeset
|
250 |
15
cbbddf99d1cd
added: filename customize function
Sushi-k <epgrec@park.mda.or.jp>
parents:
8
diff
changeset
|
251 // <ゃ腟篋 |
75
11f63ae04a96
delete trailing white space
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
71
diff
changeset
|
252 |
1 | 253 // 篋膣潟若 |
39
8965ef108821
change: modify all scripts for web base setting.
Sushi-k <epgrec@park.mda.or.jp>
parents:
15
diff
changeset
|
254 $rrec = new DBRecord( RESERVE_TBL ); |
1 | 255 $rrec->channel_disc = $crec->channel_disc; |
256 $rrec->channel_id = $crec->id; | |
257 $rrec->program_id = $program_id; | |
258 $rrec->type = $crec->type; | |
259 $rrec->channel = $crec->channel; | |
260 $rrec->title = $title; | |
261 $rrec->description = $description; | |
262 $rrec->category_id = $category_id; | |
263 $rrec->starttime = toDatetime( $rec_start ); | |
264 $rrec->endtime = toDatetime( $end_time ); | |
265 $rrec->path = $filename; | |
266 $rrec->autorec = $autorec; | |
267 $rrec->mode = $mode; | |
268 $rrec->reserve_disc = md5( $crec->channel_disc . toDatetime( $start_time ). toDatetime( $end_time ) ); | |
75
11f63ae04a96
delete trailing white space
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
71
diff
changeset
|
269 |
1 | 270 // 篋膣絎茵 |
39
8965ef108821
change: modify all scripts for web base setting.
Sushi-k <epgrec@park.mda.or.jp>
parents:
15
diff
changeset
|
271 $cmdline = $settings->at." ".date("H:i m/d/Y", $at_start); |
1 | 272 $descriptor = array( 0 => array( "pipe", "r" ), |
273 1 => array( "pipe", "w" ), | |
274 2 => array( "pipe", "w" ), | |
275 ); | |
276 $env = array( "CHANNEL" => $crec->channel, | |
277 "DURATION" => $duration, | |
39
8965ef108821
change: modify all scripts for web base setting.
Sushi-k <epgrec@park.mda.or.jp>
parents:
15
diff
changeset
|
278 "OUTPUT" => INSTALL_PATH.$settings->spool."/".$filename, |
1 | 279 "TYPE" => $crec->type, |
280 "TUNER" => $tuner, | |
281 "MODE" => $mode, | |
47 | 282 "THUMB" => INSTALL_PATH.$settings->thumbs."/".$thumbname, |
283 "FORMER" => "".$settings->former_time, | |
284 "FFMPEG" => "".$settings->ffmpeg, | |
79
6eabffb0ccac
add SID: Reservation.class.php
Sushi-k <epgrec@park.mda.or.jp>
parents:
76
diff
changeset
|
285 "SID" => $crec->sid, |
1 | 286 ); |
75
11f63ae04a96
delete trailing white space
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
71
diff
changeset
|
287 |
1 | 288 // ATт膣 |
39
8965ef108821
change: modify all scripts for web base setting.
Sushi-k <epgrec@park.mda.or.jp>
parents:
15
diff
changeset
|
289 $process = proc_open( $cmdline , $descriptor, $pipes, INSTALL_PATH.$settings->spool, $env ); |
1 | 290 if( is_resource( $process ) ) { |
39
8965ef108821
change: modify all scripts for web base setting.
Sushi-k <epgrec@park.mda.or.jp>
parents:
15
diff
changeset
|
291 fwrite($pipes[0], $settings->sleep." ".$sleep_time."\n" ); |
1 | 292 fwrite($pipes[0], DO_RECORD . "\n" ); |
293 fwrite($pipes[0], COMPLETE_CMD." ".$rrec->id."\n" ); | |
48 | 294 if( $settings->use_thumbs == 1 ) { |
56
be9e4520cfec
change: GEN_THUMBNAIL
yoneda <yoneda@recorder.localnet.mda.or.jp>
parents:
48
diff
changeset
|
295 fwrite($pipes[0], $gen_thumbnail."\n" ); |
1 | 296 } |
297 fclose($pipes[0]); | |
298 // 罔羣若 | |
299 $rstring = stream_get_contents( $pipes[2]); | |
75
11f63ae04a96
delete trailing white space
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
71
diff
changeset
|
300 |
1 | 301 fclose( $pipes[2] ); |
302 proc_close( $process ); | |
303 } | |
304 else { | |
305 $rrec->delete(); | |
149
5b192e94f49d
fix: 予約済み定数を使ってしまったミスを修正。エラーレベルに警告を追加
epgrec@park.mda.or.jp <yoneda@recorder.localnet.mda.or.jp>
parents:
142
diff
changeset
|
306 reclog( "Reservation::custom at絎茵紊掩罔≧", EPGREC_ERROR); |
1 | 307 throw new Exception("AT絎茵"); |
308 } | |
309 // job垩冴 | |
310 $rarr = array(); | |
311 $tok = strtok( $rstring, " \n" ); | |
312 while( $tok !== false ) { | |
313 array_push( $rarr, $tok ); | |
314 $tok = strtok( " \n" ); | |
315 } | |
316 $key = array_search("job", $rarr); | |
317 if( $key !== false ) { | |
318 if( is_numeric( $rarr[$key+1]) ) { | |
319 $rrec->job = $rarr[$key+1]; | |
135
9c5e597ef6c6
mod: ログ機能を追加
epgrec@park.mda.or.jp <yoneda@recorder.localnet.mda.or.jp>
parents:
134
diff
changeset
|
320 reclog( "Reservation::custom 吾с".$rrec->job."牙祉吾с脂"); |
1 | 321 return $rrec->job; // |
322 } | |
323 } | |
324 // | |
325 $rrec->delete(); | |
149
5b192e94f49d
fix: 予約済み定数を使ってしまったミスを修正。エラーレベルに警告を追加
epgrec@park.mda.or.jp <yoneda@recorder.localnet.mda.or.jp>
parents:
142
diff
changeset
|
326 reclog( "Reservation::custom job垩緇紊掩",EPGREC_ERROR ); |
1 | 327 throw new Exception( "job垩緇紊掩" ); |
328 } | |
329 catch( Exception $e ) { | |
330 if( $rrec != null ) { | |
331 if( $rrec->id ) { | |
332 // 篋膣羔 | |
333 $rrec->delete(); | |
334 } | |
335 } | |
336 throw $e; | |
337 } | |
338 } | |
339 // custom 腟篋 | |
75
11f63ae04a96
delete trailing white space
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
71
diff
changeset
|
340 |
1 | 341 // 羔 |
342 public static function cancel( $reserve_id = 0, $program_id = 0 ) { | |
39
8965ef108821
change: modify all scripts for web base setting.
Sushi-k <epgrec@park.mda.or.jp>
parents:
15
diff
changeset
|
343 $settings = Settings::factory(); |
1 | 344 $rec = null; |
75
11f63ae04a96
delete trailing white space
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
71
diff
changeset
|
345 |
1 | 346 try { |
347 if( $reserve_id ) { | |
39
8965ef108821
change: modify all scripts for web base setting.
Sushi-k <epgrec@park.mda.or.jp>
parents:
15
diff
changeset
|
348 $rec = new DBRecord( RESERVE_TBL, "id" , $reserve_id ); |
1 | 349 } |
350 else if( $program_id ) { | |
39
8965ef108821
change: modify all scripts for web base setting.
Sushi-k <epgrec@park.mda.or.jp>
parents:
15
diff
changeset
|
351 $rec = new DBRecord( RESERVE_TBL, "program_id" , $program_id ); |
1 | 352 } |
353 if( $rec == null ) { | |
354 throw new Exception("ID絎≦鴻с"); | |
355 } | |
356 if( ! $rec->complete ) { | |
357 // 絎茵篋膣с | |
135
9c5e597ef6c6
mod: ログ機能を追加
epgrec@park.mda.or.jp <yoneda@recorder.localnet.mda.or.jp>
parents:
134
diff
changeset
|
358 if( toTimestamp($rec->starttime) < (time() + PADDING_TIME + $settings->former_time) ) { |
149
5b192e94f49d
fix: 予約済み定数を使ってしまったミスを修正。エラーレベルに警告を追加
epgrec@park.mda.or.jp <yoneda@recorder.localnet.mda.or.jp>
parents:
142
diff
changeset
|
359 reclog("Reservation::cancel 絎茵篋膣羔絎茵", EPGREC_ERROR ); |
5b192e94f49d
fix: 予約済み定数を使ってしまったミスを修正。エラーレベルに警告を追加
epgrec@park.mda.or.jp <yoneda@recorder.localnet.mda.or.jp>
parents:
142
diff
changeset
|
360 throw new Exception("絎茵篋膣с"); |
135
9c5e597ef6c6
mod: ログ機能を追加
epgrec@park.mda.or.jp <yoneda@recorder.localnet.mda.or.jp>
parents:
134
diff
changeset
|
361 } |
39
8965ef108821
change: modify all scripts for web base setting.
Sushi-k <epgrec@park.mda.or.jp>
parents:
15
diff
changeset
|
362 exec( $settings->atrm . " " . $rec->job ); |
135
9c5e597ef6c6
mod: ログ機能を追加
epgrec@park.mda.or.jp <yoneda@recorder.localnet.mda.or.jp>
parents:
134
diff
changeset
|
363 reclog("Reservation::cancel 吾с".$rec->job.""); |
1 | 364 } |
365 $rec->delete(); | |
366 } | |
367 catch( Exception $e ) { | |
149
5b192e94f49d
fix: 予約済み定数を使ってしまったミスを修正。エラーレベルに警告を追加
epgrec@park.mda.or.jp <yoneda@recorder.localnet.mda.or.jp>
parents:
142
diff
changeset
|
368 reclog("Reservation::cancel 篋膣c潟祉DB・膓障≪祉鴻紊掩罔≧", EPGREC_ERROR ); |
1 | 369 throw $e; |
370 } | |
371 } | |
372 } | |
48 | 373 ?> |