トップ
$maxlen) { die_exit("$name は $len 文字以下で入力して下さい。全角文字は、一文字で二文字分と計算されます。"); } } /* LIKE 用の文字列のエスケープ */ function escape_like($sql, $quote = TRUE) { return ($quote ? "'" : "") . str_replace(array("\\\\", "%" , "_" ), array("\\\\\\\\", "\\\\%", "\\\\_"), pg_escape_string($sql)) . ($quote ? "'" : ""); } /* SQL 文字列のエスケープ */ function escape_string($sql, $quote = FALSE) { if ($quote && strlen($sql) == 0) { return "null"; } return ($quote ? "'" : "") . pg_escape_string($sql) . ($quote ? "'" : ""); } /* SQL 数値のエスケープ */ function escape_numeric($sql) { if (strlen($sql) == 0) { return "null"; } if (!is_numeric($sql)) { die_exit("$sql は数値ではありません。"); } return $sql; } /* PostgreSQL サーバに接続 */ function m_connect() { /* $con = @pg_connect("host=".DBHOST ." dbname=".DATABASE_NAME . " user=".USER_NAME . " password=".USER_PASSWORD); */ $con = @pg_pconnect("host=".DBHOST ." dbname=".DATABASE_NAME . " user=".USER_NAME . " password=".USER_PASSWORD); if (!$con) { die_exit("データベースに接続出来ませんでした。"); } /* データベースと、PHP の内部文字コードが違う場合 */ return($con); } /* データベースとの接続を切り離す */ function m_close($con) { return @pg_close($con); } /* SQL 文を実行 */ function m_query($con, $query, $errmessage) { $rtn = @pg_query($con, $query); if (!$rtn) { /* エラーメッセージに SQL 文を出すのはセキュリティ上良くない!! */ $msg = $errmessage . "
\n" . @pg_last_error($con) . "
\n" . "" . htmlspecialchars($query) . "\n"; $rtn = @pg_query($con, "rollback");//04.4.8 m_close($con); die_exit($msg); } return($rtn); } /* select した結果をテーブルで表示 */ function m_showtable($rs) { /* 検索件数 */ $maxrows = pg_num_rows($rs); if ($maxrows == 0) { echo("

データが存在しません

\n"); return 0; } /* フィールド数 */ $maxcols = pg_num_fields($rs); ?> $f_name\n"); } ?> \n"); /* pg_fetch_row で一行取り出す */ $rowdata = pg_fetch_row($rs, $row); /* 1列目にリンクを張る */ echo("\n"); for ($col = 2; $col < $maxcols; $col++) { /* 列に対応 */ echo("\n"); } echo("\n"); } ?>
" . htmlspecialchars($rowdata[1]) . "".htmlspecialchars($rowdata[$col])."
データが存在しません

\n"); return FALSE; } /* フィールド数 */ $maxcols = pg_num_fields($rs); /* 先頭行 */ $rowdata = pg_fetch_row($rs, 0); ?>
foltia | 放映予定 | 新番組 | 予約一覧 | 番組一覧 | 番組表 | 録画一覧(録画順番組順) | 録画ライブラリ | Folcast[iTunesに登録] | "; if ($useenvironmentpolicy == 1){ print "【 $username 】"; } print "

\n"; } function renderepgstation($con,$stationname,$start){ //戻り値 なし EPGの局表示 $now = date("YmdHi"); $today = date("Ymd"); $tomorrow = date ("Ymd",mktime(0, 0, 0, date("m") , date("d")+1, date("Y"))); //$today = "20051013"; //$tomorrow = "20051014"; //$epgstart = $today . "2000"; $epgstart = $start ; //$epgend = $tomorrow . "0400"; $epgend = calcendtime($start , (8*60)); $query = " SELECT startdatetime , enddatetime , lengthmin , epgtitle , epgdesc , epgcategory ,ontvchannel ,epgid FROM foltia_epg WHERE foltia_epg.ontvchannel = '$stationname' AND enddatetime > $epgstart AND startdatetime < $epgend ORDER BY foltia_epg.startdatetime ASC "; $rs = m_query($con, $query, "DBクエリに失敗しました"); $maxrows = pg_num_rows($rs); if ($maxrows == 0) { print("番組データがありません
"); }else{ print "\n"; //print " "; /*print"
  • $printstarttime $title $desc($rowdata[0] - $rowdata[1])
  • \n"; */ }//for //print "\n"; print "
    $printstarttime $title $desc
    \n"; }//if }//end function function calcendtime($start,$lengthmin){//戻り値 終了時刻(Ex:200510170130) $startyear = substr($start,0,4); $startmonth = substr($start,4,2); $startday = substr($start,6,2); $starthour = substr($start,8,2); $startmin = substr($start,10,2); //int mktime ( [int hour [, int minute [, int second [, int month [, int day [, int year [, int is_dst]]]]]]] ) $endtime = date ("YmdHi",mktime($starthour , $startmin + $lengthmin , 0, $startmonth , $startday, $startyear)); return ($endtime ); }//end function function z2h($string){ //戻り値 半角化した文字 $stringh = mb_convert_kana($string, "a", "EUC-JP"); return ($stringh ); } function foldate2rfc822($start){//戻り値 RFC822スタイルの時刻表記 $startyear = substr($start,0,4); $startmonth = substr($start,4,2); $startday = substr($start,6,2); $starthour = substr($start,8,2); $startmin = substr($start,10,2); $rfc822 = date ("r",mktime($starthour , $startmin , 0, $startmonth , $startday, $startyear)); return ($rfc822); }//end sub function foldate2print($start){//戻り値 日本語風時刻表記 $startyear = substr($start,0,4); $startmonth = substr($start,4,2); $startday = substr($start,6,2); $starthour = substr($start,8,2); $startmin = substr($start,10,2); $printabledate = date ("Y/m/d H:i",mktime($starthour , $startmin , 0, $startmonth , $startday, $startyear)); return ($printabledate); }//end sub function getserveruri(){//戻り値 サーバアドレス Ex.www.dcc-jpl.com:8800/soft/foltia/ //リンクURI組み立て $sv6 = $_SERVER['SCRIPT_NAME'];///dameNews/sarasorjyu/archives.php $sv8 = $_SERVER['SERVER_NAME'];//sync.dcc-jpl.com $sv9 = $_SERVER['SERVER_PORT']; if ($sv9 == 80){ $port = ""; }else{ $port = ":$sv9"; } $a = split("/", $sv6); array_pop($a); $scriptpath = implode("/", $a); $serveruri = "$sv8$port$scriptpath"; return ($serveruri ); }//end sub function getserverfqdn(){//戻り値 サーバアドレス Ex.www.dcc-jpl.com:8800 //リンクURI組み立て $sv6 = $_SERVER['SCRIPT_NAME'];///dameNews/sarasorjyu/archives.php $sv8 = $_SERVER['SERVER_NAME'];//sync.dcc-jpl.com $sv9 = $_SERVER['SERVER_PORT']; if ($sv9 == 80){ $port = ""; }else{ $port = ":$sv9"; } $a = split("/", $sv6); array_pop($a); $scriptpath = implode("/", $a); $serveruri = "$sv8$port"; return ($serveruri ); }//end sub function printdiskusage(){//戻り値 なし list (, $all, $use , $free, $usepercent) = getdiskusage(); print "
    $free
    $use/$all($usepercent)
    "; //exec('ps ax | grep ffmpeg |grep MP4 ' ,$ffmpegprocesses); }//end sub function getdiskusage(){//戻り値 配列 [,全体容量, 使用容量 , 空き容量, 利用割合] global $recfolderpath,$recfolderpath; exec ( "df -h $recfolderpath | grep $recfolderpath", $hdfreearea); $freearea = preg_split ("/[\s,]+/", $hdfreearea[0]); return $freearea; }//endsub function printtrcnprocesses(){ $ffmpegprocesses = `ps ax | grep ffmpeg | grep -v grep | wc -l `; $uptime = exec('uptime'); print "
    "; print "$uptime
    \n"; print "トラコン稼働数:$ffmpegprocesses
    \n"; print "
    "; }//endsub function warndiskfreearea(){ global $demomode; if ($demomode){ print ""; }else{ global $recfolderpath,$hdfreearea ; exec ( "df $recfolderpath | grep $recfolderpath", $hdfreearea); $freearea = preg_split ("/[\s,]+/", $hdfreearea[0]); $freebytes = $freearea[3]; if ($freebytes == "" ){ // //print ""; }elseif($freebytes > 1024*1024*100 ){// 100GB以上あいてれば //なにもしない print ""; }elseif($freebytes > 1024*1024*50 ){// 100GB以下 print " "; }elseif($freebytes > 1024*1024*30 ){// 50GB以下 print " "; }elseif($freebytes > 0 ){// 30GB以下 print " "; }else{ //空き容量 0バイト print " "; }//endif freebytess }//endif demomode }//endsub function foldatevalidation($foldate){ if (strlen($foldate) == 12 ){ $startyear = substr($foldate,0,4); $startmonth = substr($foldate,4,2); $startday = substr($foldate,6,2); $starthour = substr($foldate,8,2); $startmin = substr($foldate,10,2); $startepoch = date ("U",mktime($starthour , $startmin , 0, $startmonth , $startday, $startyear)); $nowe = time(); if ($startepoch > $nowe){ //print "$foldate:$startepoch:$nowe"; return TRUE; }else{ return FALSE; } //end if $startepoch > $nowe }else{ return FALSE; }//end if ($foldate) == 12 }//end function function login($con,$name,$passwd){ global $environmentpolicytoken; //入力内容確認 if (((mb_ereg('[^0-9a-zA-Z]', $name)) ||(mb_ereg('[^0-9a-zA-Z]', $passwd) ))){ //print "エラー処理\n"; //print ""; redirectlogin(); }else{ //print "正常処理\n"; //db検索 escape_string($name); escape_string($passwd); $query = " SELECT memberid ,userclass,name,passwd1 FROM foltia_envpolicy WHERE foltia_envpolicy.name = '$name' "; $useraccount = m_query($con, $query, "DBクエリに失敗しました"); $useraccountrows = pg_num_rows($useraccount); if ($useraccountrows == 1 ){ $rowdata = pg_fetch_row($useraccount, 0); $memberid = $rowdata[0]; $userclass = $rowdata[1]; $username = $rowdata[2]; $dbpasswd = $rowdata[3]; }else{ header("HTTP/1.0 401 Unauthorized"); //print ""; redirectlogin(); }//end if // passwdをdbから取りだし if ($userclass == 0){ $dbpasswd = "$dbpasswd"; }else{ // db passwdとトークンを連結し $dbpasswd = "$dbpasswd"."$environmentpolicytoken"; } //それが入力と一致すれば認証 if ($passwd == $dbpasswd) { //print "認証成功
    $dbpasswd $passwd\n"; }else{ //print "認証失敗
    $dbpasswd $passwd\n"; header("HTTP/1.0 401 Unauthorized"); //print "