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