トップ
$maxlen) { die_exit("$name は $len 文字以下で入力して下さい。全角文字は、一文字で二文字分と計算されます。"); } } /* SQL 文字列のエスケープ */ function escape_string($sql, $quote = FALSE) { if ($quote && strlen($sql) == 0) { return "null"; } if (preg_match("/^pgsql/", DSN)){ return ($quote ? "'" : "") . pg_escape_string($sql) . ($quote ? "'" : ""); }else if (preg_match("/^sqlite/", DSN)){ /* return ($quote ? "'" : "") . sqlite_escape_string($sql) . ($quote ? "'" : ""); */ return($sql); }else{ return "null"; } } /* SQL 数値のエスケープ */ function escape_numeric($sql) { if (strlen($sql) == 0) { return "null"; } if (!is_numeric($sql)) { die_exit("$sql は数値ではありません。"); } return $sql; } /* DBに接続 */ function m_connect() { try { $dbh = new PDO(DSN); $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); return($dbh); } catch (PDOException $e) { die_exit($e->getMessage() . ": データベースに接続出来ませんでした。"); } /* データベースと、PHP の内部文字コードが違う場合 */ } /* データベースとの接続を切り離す */ function m_close($dbh) { return null; } //旧関数 sql_queryに置き換え function m_query($dbh, $query, $errmessage) { try { $rtn = $dbh->query($query); return($rtn); } catch (PDOException $e) { /* エラーメッセージに SQL 文を出すのはセキュリティ上良くない!! */ $msg = $errmessage . "
\n" . $e->getMessage() . "
\n" . var_export($e->errorInfo, true) . "
\n" . "" . htmlspecialchars($query) . "\n"; // $dbh->rollBack(); $dbh = null; die_exit($msg); } } /* SQL 文を実行 */ function sql_query($dbh, $query, $errmessage,$paramarray) { try { $rtn = $dbh->prepare("$query"); $rtn->execute($paramarray); return($rtn); } catch (PDOException $e) { /* エラーメッセージに SQL 文を出すのはセキュリティ上良くない!! */ $msg = $errmessage . "
\n" . $e->getMessage() . "
\n" . var_export($e->errorInfo, true) . "
\n" . "" . htmlspecialchars($query) . "\n"; // $dbh->rollBack(); $dbh = null; die_exit($msg); } } /* select した結果をテーブルで表示 */ function m_showtable($rs) { /* 検索件数 */ $maxrows = 0; $rowdata = $rs->fetch(); if (! $rowdata) { echo("

データが存在しません

\n"); return 0; } /* フィールド数 */ $maxcols = $rs->columnCount(); ?> getColumnMeta($col); $f_name = htmlspecialchars($meta["name"]); echo("\n"); } ?> \n"); /* 1列目にリンクを張る */ echo("\n"); for ($col = 2; $col < $maxcols; $col++) { /* 列に対応 */ echo("\n"); } echo("\n"); } while ($rowdata = $rs->fetch()); ?>
$f_name
" . htmlspecialchars($rowdata[1]) . "".htmlspecialchars($rowdata[$col])."
fetch(); if (! $rowdata) { echo("

データが存在しません

\n"); return FALSE; } // フィールド数 $maxcols = $rs->columnCount(); ?> getColumnMeta(1); ?> getColumnMeta($col); ?>
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クエリに失敗しました"); $rowdata = $rs->fetch(); if (! $rowdata) { print("番組データがありません
"); }else{ print "\n"; //print " "; /*print"
  • $printstarttime $title $desc($rowdata[0] - $rowdata[1])
  • \n"; */ } while ($rowdata = $rs->fetch());//do //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]); exec ( "df -hP $recfolderpath", $hdfreearea); $freearea = preg_split ("/[\s,]+/", $hdfreearea[count($hdfreearea)-1]); 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クエリに失敗しました"); $rowdata = $useraccount->fetch(); if (! $rowdata) { header("HTTP/1.0 401 Unauthorized"); redirectlogin(); } $memberid = $rowdata[0]; $userclass = $rowdata[1]; $username = $rowdata[2]; $dbpasswd = $rowdata[3]; $rowdata = $useraccount->fetch(); if ($rowdata) { header("HTTP/1.0 401 Unauthorized"); redirectlogin(); } // 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 "