1 |
<?php |
---|
2 |
|
---|
3 |
include("./foltia_config2.php"); |
---|
4 |
|
---|
5 |
|
---|
6 |
|
---|
7 |
|
---|
8 |
|
---|
9 |
|
---|
10 |
|
---|
11 |
|
---|
12 |
|
---|
13 |
|
---|
14 |
|
---|
15 |
|
---|
16 |
|
---|
17 |
|
---|
18 |
function getgetform($key) { |
---|
19 |
$_GET["{$key}"] != "") { |
---|
20 |
$value = $_GET["{$key}"]; |
---|
21 |
escape_string($value); |
---|
22 |
htmlspecialchars($value); |
---|
23 |
$value); |
---|
24 |
|
---|
25 |
|
---|
26 |
|
---|
27 |
function getgetnumform($key) { |
---|
28 |
$_GET["{$key}"] != "") { |
---|
29 |
$value = $_GET["{$key}"]; |
---|
30 |
escape_string($value); |
---|
31 |
htmlspecialchars($value); |
---|
32 |
$value = ereg_replace("[^0-9]", "", $value); |
---|
33 |
$value = escape_numeric($value); |
---|
34 |
$value); |
---|
35 |
|
---|
36 |
|
---|
37 |
|
---|
38 |
|
---|
39 |
function getform($key) { |
---|
40 |
|
---|
41 |
if ($_POST["{$key}"] != "") { |
---|
42 |
$value = $_POST["{$key}"]; |
---|
43 |
escape_string($value); |
---|
44 |
htmlspecialchars($value); |
---|
45 |
$value); |
---|
46 |
|
---|
47 |
|
---|
48 |
|
---|
49 |
function getnumform($key) { |
---|
50 |
$_POST["{$key}"] != "") { |
---|
51 |
$value = $_POST["{$key}"]; |
---|
52 |
escape_string($value); |
---|
53 |
htmlspecialchars($value); |
---|
54 |
$value = ereg_replace("[^0-9]", "", $value); |
---|
55 |
$value = escape_numeric($value); |
---|
56 |
$value); |
---|
57 |
|
---|
58 |
|
---|
59 |
|
---|
60 |
|
---|
61 |
function name2read($name) { |
---|
62 |
$name = mb_convert_kana($name, "KVC", "EUC-JP"); |
---|
63 |
$name = mb_convert_kana($name, "s", "EUC-JP"); |
---|
64 |
$name = ereg_replace(" ", "", $name); |
---|
65 |
|
---|
66 |
$name; |
---|
67 |
|
---|
68 |
|
---|
69 |
|
---|
70 |
function pnum2dnum($num) { |
---|
71 |
$num = mb_convert_kana($num, "a", "EUC-JP"); |
---|
72 |
$num = ereg_replace("[^0-9]", "", $num); |
---|
73 |
|
---|
74 |
$num; |
---|
75 |
|
---|
76 |
|
---|
77 |
|
---|
78 |
function die_exit($message) { |
---|
79 |
?> |
---|
80 |
<p class="error"><?= $message ?></p> |
---|
81 |
<div class="index"><a href="./">トップ</a></div> |
---|
82 |
</body> |
---|
83 |
</html><? |
---|
84 |
exit; |
---|
85 |
} |
---|
86 |
|
---|
87 |
|
---|
88 |
function check_length($str, $maxlen, $must, $name) { |
---|
89 |
$len = strlen($str); |
---|
90 |
if ($must && $len == 0) { |
---|
91 |
die_exit("$name が入力されてません。必須項目です。"); |
---|
92 |
} |
---|
93 |
if ($len > $maxlen) { |
---|
94 |
die_exit("$name は $len 文字以下で入力して下さい。全角文字は、一文字で二文字分と計算されます。"); |
---|
95 |
} |
---|
96 |
} |
---|
97 |
|
---|
98 |
|
---|
99 |
function escape_like($sql, $quote = TRUE) { |
---|
100 |
return ($quote ? "'" : "") . |
---|
101 |
str_replace(array("\\\\", "%" , "_" ), |
---|
102 |
array("\\\\\\\\", "\\\\%", "\\\\_"), |
---|
103 |
pg_escape_string($sql)) . |
---|
104 |
($quote ? "'" : ""); |
---|
105 |
} |
---|
106 |
|
---|
107 |
|
---|
108 |
function escape_string($sql, $quote = TRUE) { |
---|
109 |
if ($quote && strlen($sql) == 0) { |
---|
110 |
return "null"; |
---|
111 |
} |
---|
112 |
return ($quote ? "'" : "") . |
---|
113 |
pg_escape_string($sql) . |
---|
114 |
($quote ? "'" : ""); |
---|
115 |
} |
---|
116 |
|
---|
117 |
|
---|
118 |
function escape_numeric($sql) { |
---|
119 |
if (strlen($sql) == 0) { |
---|
120 |
return "null"; |
---|
121 |
} |
---|
122 |
if (!is_numeric($sql)) { |
---|
123 |
die_exit("$sql は数値ではありません。"); |
---|
124 |
} |
---|
125 |
return $sql; |
---|
126 |
} |
---|
127 |
|
---|
128 |
|
---|
129 |
function m_connect() { |
---|
130 |
|
---|
131 |
|
---|
132 |
|
---|
133 |
|
---|
134 |
$con = @pg_pconnect("host=".DBHOST ." dbname=".DATABASE_NAME . |
---|
135 |
" user=".USER_NAME . |
---|
136 |
" password=".USER_PASSWORD); |
---|
137 |
|
---|
138 |
|
---|
139 |
$con) { |
---|
140 |
die_exit("データベースに接続出来ませんでした。"); |
---|
141 |
|
---|
142 |
|
---|
143 |
return($con); |
---|
144 |
|
---|
145 |
|
---|
146 |
|
---|
147 |
function m_close($con) { |
---|
148 |
pg_close($con); |
---|
149 |
|
---|
150 |
|
---|
151 |
|
---|
152 |
function m_query($con, $query, $errmessage) { |
---|
153 |
$rtn = @pg_query($con, $query); |
---|
154 |
$rtn) { |
---|
155 |
|
---|
156 |
$msg = $errmessage . "<br>\n" . |
---|
157 |
pg_last_error($con) . "<br>\n" . |
---|
158 |
"<small><code>" . htmlspecialchars($query) . |
---|
159 |
"</code></small>\n"; |
---|
160 |
$rtn = @pg_query($con, "rollback"); |
---|
161 |
m_close($con); |
---|
162 |
die_exit($msg); |
---|
163 |
|
---|
164 |
$rtn); |
---|
165 |
|
---|
166 |
|
---|
167 |
|
---|
168 |
function m_showtable($rs) { |
---|
169 |
|
---|
170 |
$maxrows = pg_num_rows($rs); |
---|
171 |
|
---|
172 |
$maxrows == 0) { |
---|
173 |
"<p class=\"msg\">データが存在しません</p>\n"); |
---|
174 |
0; |
---|
175 |
|
---|
176 |
|
---|
177 |
|
---|
178 |
$maxcols = pg_num_fields($rs); |
---|
179 |
?> |
---|
180 |
<table class="list" summary="データ検索結果を表示" border="1"> |
---|
181 |
<thead> |
---|
182 |
<tr> |
---|
183 |
<?php |
---|
184 |
|
---|
185 |
for ($col = 1; $col < $maxcols; $col++) { |
---|
186 |
|
---|
187 |
$f_name = htmlspecialchars(pg_field_name($rs, $col)); |
---|
188 |
echo("<th abbr=\"$f_name\">$f_name</th>\n"); |
---|
189 |
} |
---|
190 |
?> |
---|
191 |
</tr> |
---|
192 |
</thead> |
---|
193 |
<tbody> |
---|
194 |
<?php |
---|
195 |
|
---|
196 |
for ($row = 0; $row < $maxrows; $row++) { |
---|
197 |
echo("<tr>\n"); |
---|
198 |
|
---|
199 |
$rowdata = pg_fetch_row($rs, $row); |
---|
200 |
|
---|
201 |
echo("<td><a href=\"edit.php?q_code=" . |
---|
202 |
urlencode($rowdata[0]) . "\">" . |
---|
203 |
htmlspecialchars($rowdata[1]) . "</a></td>\n"); |
---|
204 |
for ($col = 2; $col < $maxcols; $col++) { |
---|
205 |
echo("<td>".htmlspecialchars($rowdata[$col])."<br></td>\n"); |
---|
206 |
} |
---|
207 |
echo("</tr>\n"); |
---|
208 |
} |
---|
209 |
?> |
---|
210 |
</tbody> |
---|
211 |
</table> |
---|
212 |
<?php |
---|
213 |
return $maxrows; |
---|
214 |
} |
---|
215 |
|
---|
216 |
|
---|
217 |
function m_viewdata($con, $code) { |
---|
218 |
|
---|
219 |
$query = " |
---|
220 |
select p.code |
---|
221 |
,p.name |
---|
222 |
,p.email |
---|
223 |
,p.pseudonym |
---|
224 |
,s.name as job |
---|
225 |
,p.profile |
---|
226 |
,to_char(p.editdate, 'YYYY/MM/DD HH24:MI:SS') as editdate |
---|
227 |
from inet_profile p left join inet_job s on p.job = s.code |
---|
228 |
where p.code = $code"; |
---|
229 |
$rs = m_query($con, $query, "個人情報の取得に失敗しました。"); |
---|
230 |
if (pg_num_rows($rs) == 0) { |
---|
231 |
echo("<p class=\"msg\">データが存在しません</p>\n"); |
---|
232 |
return FALSE; |
---|
233 |
} |
---|
234 |
|
---|
235 |
|
---|
236 |
$maxcols = pg_num_fields($rs); |
---|
237 |
|
---|
238 |
$rowdata = pg_fetch_row($rs, 0); |
---|
239 |
?> |
---|
240 |
<table class="view" summary="データベース上のデータを表示" border="1"> |
---|
241 |
<tr> |
---|
242 |
<td class="name"><?= htmlspecialchars(pg_field_name($rs, 1)) ?></td> |
---|
243 |
<td><a href="edit.php?q_code=<?= $rowdata[0] ?>" |
---|
244 |
><?= htmlspecialchars($rowdata[1]) ?></a></td> |
---|
245 |
</tr> |
---|
246 |
<?php for ($col = 2; $col < $maxcols; $col++) { ?> |
---|
247 |
<tr> |
---|
248 |
<td class="name"><?= htmlspecialchars(pg_field_name($rs, $col)) ?></td> |
---|
249 |
<td><?= htmlspecialchars($rowdata[$col]) ?></td> |
---|
250 |
</tr> |
---|
251 |
<?php } ?> |
---|
252 |
</table> |
---|
253 |
<?php |
---|
254 |
|
---|
255 |
pg_free_result($rs); |
---|
256 |
|
---|
257 |
return TRUE; |
---|
258 |
} |
---|
259 |
|
---|
260 |
|
---|
261 |
function printhtmlpageheader(){ |
---|
262 |
|
---|
263 |
$serveruri = getserveruri(); |
---|
264 |
|
---|
265 |
print "<p align='left'><font color='#494949'><A HREF = 'http://www.dcc-jpl.com/soft/foltia/' target=\"_blank\">foltia</A> | <A HREF = './index.php'>放映予定</A> | <A HREF = './index.php?mode=new'>新番組</A> | <A HREF = './listreserve.php'>予約一覧</A> | <A HREF = './titlelist.php'>番組一覧</A> | <A HREF = './viewepg.php'>番組表</A> | 録画一覧(<A HREF = './showplaylist.php'>録画順</A>・<A HREF = './showplaylist.php?list=title'>番組順</A>・<A HREF = './showplaylist.php?list=raw'>全</A>) | <A HREF = './showlib.php'>録画ライブラリ</A> | <A HREF = './folcast.php'>Folcast(RSS)</A>[<a href=\"itpc://$serveruri/folcast.php\">iTunesにFolcastを登録</a>] |</font></p>\n"; |
---|
266 |
|
---|
267 |
} |
---|
268 |
|
---|
269 |
|
---|
270 |
function renderepgstation($con,$stationname,$start){ |
---|
271 |
|
---|
272 |
$now = date("YmdHi"); |
---|
273 |
$today = date("Ymd"); |
---|
274 |
$tomorrow = date ("Ymd",mktime(0, 0, 0, date("m") , date("d")+1, date("Y"))); |
---|
275 |
|
---|
276 |
|
---|
277 |
|
---|
278 |
$epgstart = $start ; |
---|
279 |
|
---|
280 |
$epgend = calcendtime($start , (8*60)); |
---|
281 |
$query = " |
---|
282 |
SELECT startdatetime , enddatetime , lengthmin , epgtitle , epgdesc , epgcategory ,ontvchannel ,epgid |
---|
283 |
FROM foltia_epg |
---|
284 |
WHERE foltia_epg.ontvchannel = '$stationname' AND |
---|
285 |
enddatetime > $epgstart AND |
---|
286 |
startdatetime < $epgend |
---|
287 |
ORDER BY foltia_epg.startdatetime ASC |
---|
288 |
"; |
---|
289 |
$rs = m_query($con, $query, "DBクエリに失敗しました"); |
---|
290 |
$maxrows = pg_num_rows($rs); |
---|
291 |
if ($maxrows == 0) { |
---|
292 |
print("番組データがありません<BR>"); |
---|
293 |
}else{ |
---|
294 |
print "<table width=\"100%\" border=\"0\">\n"; |
---|
295 |
|
---|
296 |
|
---|
297 |
for ($row = 0; $row < $maxrows; $row++) { |
---|
298 |
|
---|
299 |
$rowdata = pg_fetch_row($rs, $row); |
---|
300 |
|
---|
301 |
$printstarttime = substr($rowdata[0],8,2) . ":" . substr($rowdata[0],10,2); |
---|
302 |
$tdclass = "t".substr($rowdata[0],8,2) . substr($rowdata[0],10,2); |
---|
303 |
$title = htmlspecialchars($rowdata[3]); |
---|
304 |
$title = z2h($title); |
---|
305 |
$desc = htmlspecialchars($rowdata[4]); |
---|
306 |
$desc = z2h($desc); |
---|
307 |
$height = htmlspecialchars($rowdata[2]) * 3; |
---|
308 |
$epgid = htmlspecialchars($rowdata[7]); |
---|
309 |
|
---|
310 |
print" |
---|
311 |
<tr> |
---|
312 |
<td height = \"$height\" >$printstarttime <A HREF=\"./reserveepg.php?epgid=$epgid\">$title</A> $desc <!-- $rowdata[0] - $rowdata[1] --></td> |
---|
313 |
</tr> |
---|
314 |
"; |
---|
315 |
|
---|
316 |
|
---|
317 |
|
---|
318 |
|
---|
319 |
} |
---|
320 |
//print "</ul>\n"; |
---|
321 |
print "</table>\n"; |
---|
322 |
|
---|
323 |
} |
---|
324 |
} |
---|
325 |
|
---|
326 |
function calcendtime($start,$lengthmin){ |
---|
327 |
$startyear = substr($start,0,4); |
---|
328 |
$startmonth = substr($start,4,2); |
---|
329 |
$startday = substr($start,6,2); |
---|
330 |
$starthour = substr($start,8,2); |
---|
331 |
$startmin = substr($start,10,2); |
---|
332 |
|
---|
333 |
$endtime = date ("YmdHi",mktime($starthour , $startmin + $lengthmin , 0, $startmonth , $startday, $startyear)); |
---|
334 |
|
---|
335 |
return ($endtime ); |
---|
336 |
} |
---|
337 |
|
---|
338 |
|
---|
339 |
function z2h($string){ |
---|
340 |
$stringh = mb_convert_kana($string, "a", "EUC-JP"); |
---|
341 |
return ($stringh ); |
---|
342 |
} |
---|
343 |
|
---|
344 |
function foldate2rfc822($start){ |
---|
345 |
$startyear = substr($start,0,4); |
---|
346 |
$startmonth = substr($start,4,2); |
---|
347 |
$startday = substr($start,6,2); |
---|
348 |
$starthour = substr($start,8,2); |
---|
349 |
$startmin = substr($start,10,2); |
---|
350 |
|
---|
351 |
$rfc822 = date ("r",mktime($starthour , $startmin , 0, $startmonth , $startday, $startyear)); |
---|
352 |
|
---|
353 |
return ($rfc822); |
---|
354 |
} |
---|
355 |
|
---|
356 |
function foldate2print($start){ |
---|
357 |
$startyear = substr($start,0,4); |
---|
358 |
$startmonth = substr($start,4,2); |
---|
359 |
$startday = substr($start,6,2); |
---|
360 |
$starthour = substr($start,8,2); |
---|
361 |
$startmin = substr($start,10,2); |
---|
362 |
|
---|
363 |
$printabledate = date ("Y/m/d H:i",mktime($starthour , $startmin , 0, $startmonth , $startday, $startyear)); |
---|
364 |
return ($printabledate); |
---|
365 |
} |
---|
366 |
|
---|
367 |
function getserveruri(){ |
---|
368 |
|
---|
369 |
//リンクURI組み立て |
---|
370 |
$sv6 = $_SERVER['SCRIPT_NAME']; |
---|
371 |
$sv8 = $_SERVER['SERVER_NAME']; |
---|
372 |
$sv9 = $_SERVER['SERVER_PORT']; |
---|
373 |
if ($sv9 == 80){ |
---|
374 |
$port = ""; |
---|
375 |
}else{ |
---|
376 |
$port = ":$sv9"; |
---|
377 |
} |
---|
378 |
$a = split("/", $sv6); |
---|
379 |
array_pop($a); |
---|
380 |
|
---|
381 |
$scriptpath = implode("/", $a); |
---|
382 |
|
---|
383 |
$serveruri = "$sv8$port$scriptpath"; |
---|
384 |
return ($serveruri ); |
---|
385 |
} |
---|
386 |
|
---|
387 |
|
---|
388 |
function getserverfqdn(){ |
---|
389 |
|
---|
390 |
//リンクURI組み立て |
---|
391 |
$sv6 = $_SERVER['SCRIPT_NAME']; |
---|
392 |
$sv8 = $_SERVER['SERVER_NAME']; |
---|
393 |
$sv9 = $_SERVER['SERVER_PORT']; |
---|
394 |
if ($sv9 == 80){ |
---|
395 |
$port = ""; |
---|
396 |
}else{ |
---|
397 |
$port = ":$sv9"; |
---|
398 |
} |
---|
399 |
$a = split("/", $sv6); |
---|
400 |
array_pop($a); |
---|
401 |
|
---|
402 |
$scriptpath = implode("/", $a); |
---|
403 |
|
---|
404 |
$serveruri = "$sv8$port"; |
---|
405 |
return ($serveruri ); |
---|
406 |
} |
---|
407 |
|
---|
408 |
|
---|
409 |
function printdiskusage(){ |
---|
410 |
list (, $all, $use , $free, $usepercent) = getdiskusage(); |
---|
411 |
|
---|
412 |
print " |
---|
413 |
<div style=\"width:100%;border:1px solid black;text-align:left;\"><span style=\"float:right;\">$free</span> |
---|
414 |
<div style=\"width:$usepercent;border:1px solid black;background:white;\">$use/$all($usepercent)</div> |
---|
415 |
</div> |
---|
416 |
"; |
---|
417 |
|
---|
418 |
} |
---|
419 |
|
---|
420 |
|
---|
421 |
function getdiskusage(){ |
---|
422 |
|
---|
423 |
global $recfolderpath,$recfolderpath; |
---|
424 |
|
---|
425 |
exec ( "df -h $recfolderpath | grep $recfolderpath", $hdfreearea); |
---|
426 |
$freearea = preg_split ("/[\s,]+/", $hdfreearea[0]); |
---|
427 |
|
---|
428 |
return $freearea; |
---|
429 |
|
---|
430 |
} |
---|
431 |
|
---|
432 |
|
---|
433 |
function printtrcnprocesses(){ |
---|
434 |
|
---|
435 |
$ffmpegprocesses = `ps ax | grep ffmpeg | grep -v grep | wc -l `; |
---|
436 |
$uptime = exec('uptime'); |
---|
437 |
|
---|
438 |
print "<div style=\"text-align:left;\">"; |
---|
439 |
print "$uptime<br>\n"; |
---|
440 |
print "トラコン稼働数:$ffmpegprocesses<br>\n"; |
---|
441 |
print "</div>"; |
---|
442 |
|
---|
443 |
} |
---|
444 |
|
---|
445 |
|
---|
446 |
function warndiskfreearea(){ |
---|
447 |
|
---|
448 |
global $demomode; |
---|
449 |
|
---|
450 |
if ($demomode){ |
---|
451 |
print "<!-- demo mode -->"; |
---|
452 |
}else{ |
---|
453 |
|
---|
454 |
global $recfolderpath,$hdfreearea ; |
---|
455 |
|
---|
456 |
exec ( "df $recfolderpath | grep $recfolderpath", $hdfreearea); |
---|
457 |
$freearea = preg_split ("/[\s,]+/", $hdfreearea[0]); |
---|
458 |
$freebytes = $freearea[3]; |
---|
459 |
if ($freebytes == "" ){ |
---|
460 |
|
---|
461 |
|
---|
462 |
}elseif($freebytes > 1024*1024*100 ){ |
---|
463 |
//なにもしない |
---|
464 |
print "<style type=\"text/css\"><!-- --></style>"; |
---|
465 |
}elseif($freebytes > 1024*1024*50 ){ |
---|
466 |
print "<style type=\"text/css\"><!-- |
---|
467 |
body { |
---|
468 |
background-color: #CCCC99; |
---|
469 |
} |
---|
470 |
--> |
---|
471 |
</style> |
---|
472 |
"; |
---|
473 |
}elseif($freebytes > 1024*1024*30 ){ |
---|
474 |
print "<style type=\"text/css\"><!-- |
---|
475 |
body { |
---|
476 |
background-color:#CC6666; |
---|
477 |
} |
---|
478 |
--> |
---|
479 |
</style> |
---|
480 |
"; |
---|
481 |
}elseif($freebytes > 0 ){ |
---|
482 |
print "<style type=\"text/css\"><!-- |
---|
483 |
body { |
---|
484 |
background-color:#FF0000; |
---|
485 |
} |
---|
486 |
--> |
---|
487 |
</style> |
---|
488 |
"; |
---|
489 |
}else{ |
---|
490 |
|
---|
491 |
|
---|
492 |
|
---|
493 |
} |
---|
494 |
|
---|
495 |
} |
---|
496 |
|
---|
497 |
} |
---|
498 |
|
---|
499 |
|
---|
500 |
|
---|
501 |
function foldatevalidation($foldate){ |
---|
502 |
|
---|
503 |
if (strlen($foldate) == 12 ){ |
---|
504 |
|
---|
505 |
$startyear = substr($foldate,0,4); |
---|
506 |
$startmonth = substr($foldate,4,2); |
---|
507 |
$startday = substr($foldate,6,2); |
---|
508 |
$starthour = substr($foldate,8,2); |
---|
509 |
$startmin = substr($foldate,10,2); |
---|
510 |
|
---|
511 |
$startepoch = date ("U",mktime($starthour , $startmin , 0, $startmonth , $startday, $startyear)); |
---|
512 |
$nowe = time(); |
---|
513 |
if ($startepoch > $nowe){ |
---|
514 |
|
---|
515 |
return TRUE; |
---|
516 |
}else{ |
---|
517 |
return FALSE; |
---|
518 |
} |
---|
519 |
}else{ |
---|
520 |
return FALSE; |
---|
521 |
} |
---|
522 |
|
---|
523 |
} |
---|
524 |
|
---|
525 |
|
---|
526 |
|
---|
527 |
|
---|
528 |
|
---|
529 |
|
---|
530 |
|
---|
531 |
|
---|
532 |
|
---|
533 |
|
---|
534 |
|
---|
535 |
|
---|
536 |
|
---|
537 |
|
---|
538 |
|
---|
539 |
?> |
---|
540 |
|
---|