| 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 | 
$value = escape_string($value); | 
|---|
| 22 | 
$value = htmlspecialchars($value); | 
|---|
| 23 | 
$value); | 
|---|
| 24 | 
 | 
|---|
| 25 | 
 | 
|---|
| 26 | 
 | 
|---|
| 27 | 
function getgetnumform($key) { | 
|---|
| 28 | 
 | 
|---|
| 29 | 
if (isset($_GET["{$key}"] )) { | 
|---|
| 30 | 
$value = $_GET["{$key}"]; | 
|---|
| 31 | 
$value = ereg_replace("[^-0-9]", "", $value); | 
|---|
| 32 | 
$value = escape_numeric($value); | 
|---|
| 33 | 
$value); | 
|---|
| 34 | 
 | 
|---|
| 35 | 
 | 
|---|
| 36 | 
 | 
|---|
| 37 | 
 | 
|---|
| 38 | 
function getform($key) { | 
|---|
| 39 | 
$_POST["{$key}"] != "") { | 
|---|
| 40 | 
$value = $_POST["{$key}"]; | 
|---|
| 41 | 
$value = escape_string($value); | 
|---|
| 42 | 
$value = htmlspecialchars($value); | 
|---|
| 43 | 
$value); | 
|---|
| 44 | 
 | 
|---|
| 45 | 
 | 
|---|
| 46 | 
 | 
|---|
| 47 | 
function getnumform($key) { | 
|---|
| 48 | 
$_POST["{$key}"] != "") { | 
|---|
| 49 | 
$value = $_POST["{$key}"]; | 
|---|
| 50 | 
$value = escape_string($value); | 
|---|
| 51 | 
$value = htmlspecialchars($value); | 
|---|
| 52 | 
$value = ereg_replace("[^0-9]", "", $value); | 
|---|
| 53 | 
$value = escape_numeric($value); | 
|---|
| 54 | 
$value); | 
|---|
| 55 | 
 | 
|---|
| 56 | 
 | 
|---|
| 57 | 
 | 
|---|
| 58 | 
 | 
|---|
| 59 | 
function name2read($name) { | 
|---|
| 60 | 
$name = mb_convert_kana($name, "KVC", "EUC-JP"); | 
|---|
| 61 | 
$name = mb_convert_kana($name, "s", "EUC-JP"); | 
|---|
| 62 | 
$name = ereg_replace(" ", "", $name); | 
|---|
| 63 | 
 | 
|---|
| 64 | 
$name; | 
|---|
| 65 | 
 | 
|---|
| 66 | 
 | 
|---|
| 67 | 
 | 
|---|
| 68 | 
function pnum2dnum($num) { | 
|---|
| 69 | 
$num = mb_convert_kana($num, "a", "EUC-JP"); | 
|---|
| 70 | 
$num = ereg_replace("[^0-9]", "", $num); | 
|---|
| 71 | 
 | 
|---|
| 72 | 
$num; | 
|---|
| 73 | 
 | 
|---|
| 74 | 
 | 
|---|
| 75 | 
 | 
|---|
| 76 | 
function die_exit($message) { | 
|---|
| 77 | 
?> | 
|---|
| 78 | 
        <p class="error"><?php print "$message"; ?></p> | 
|---|
| 79 | 
        <div class="index"><a href="./">トップ</a></div> | 
|---|
| 80 | 
    </body> | 
|---|
| 81 | 
</html><?php | 
|---|
| 82 | 
        exit; | 
|---|
| 83 | 
    } | 
|---|
| 84 | 
     | 
|---|
| 85 | 
     | 
|---|
| 86 | 
    function check_length($str, $maxlen, $must, $name) { | 
|---|
| 87 | 
        $len = strlen($str); | 
|---|
| 88 | 
        if ($must && $len == 0) { | 
|---|
| 89 | 
            die_exit("$name が入力されてません。必須項目です。"); | 
|---|
| 90 | 
        } | 
|---|
| 91 | 
        if ($len > $maxlen) { | 
|---|
| 92 | 
            die_exit("$name は $len 文字以下で入力して下さい。全角文字は、一文字で二文字分と計算されます。"); | 
|---|
| 93 | 
        } | 
|---|
| 94 | 
    } | 
|---|
| 95 | 
 | 
|---|
| 96 | 
     | 
|---|
| 97 | 
    function escape_string($sql, $quote = FALSE) { | 
|---|
| 98 | 
        if ($quote && strlen($sql) == 0) { | 
|---|
| 99 | 
            return "null"; | 
|---|
| 100 | 
        } | 
|---|
| 101 | 
        if (preg_match("/^pgsql/", DSN)){ | 
|---|
| 102 | 
        return ($quote ? "'" : "") . | 
|---|
| 103 | 
               pg_escape_string($sql) . | 
|---|
| 104 | 
               ($quote ? "'" : ""); | 
|---|
| 105 | 
        }else if (preg_match("/^sqlite/", DSN)){ | 
|---|
| 106 | 
         | 
|---|
| 107 | 
                sqlite_escape_string($sql) . | 
|---|
| 108 | 
                ($quote ? "'" : ""); | 
|---|
| 109 | 
        */ | 
|---|
| 110 | 
        return($sql); | 
|---|
| 111 | 
        }else{ | 
|---|
| 112 | 
            return "null"; | 
|---|
| 113 | 
        } | 
|---|
| 114 | 
    }  | 
|---|
| 115 | 
     | 
|---|
| 116 | 
     | 
|---|
| 117 | 
    function escape_numeric($sql) { | 
|---|
| 118 | 
        if (strlen($sql) == 0) { | 
|---|
| 119 | 
            return "null"; | 
|---|
| 120 | 
        } | 
|---|
| 121 | 
        if (!is_numeric($sql)) { | 
|---|
| 122 | 
            die_exit("$sql は数値ではありません。"); | 
|---|
| 123 | 
        } | 
|---|
| 124 | 
        return $sql; | 
|---|
| 125 | 
    } | 
|---|
| 126 | 
     | 
|---|
| 127 | 
     | 
|---|
| 128 | 
    function m_connect() {  | 
|---|
| 129 | 
    try { | 
|---|
| 130 | 
        $dbh = new PDO(DSN); | 
|---|
| 131 | 
        $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); | 
|---|
| 132 | 
        return($dbh); | 
|---|
| 133 | 
    } catch (PDOException $e) { | 
|---|
| 134 | 
        die_exit($e->getMessage() . ": データベースに接続出来ませんでした。"); | 
|---|
| 135 | 
        } | 
|---|
| 136 | 
         | 
|---|
| 137 | 
    } | 
|---|
| 138 | 
 | 
|---|
| 139 | 
     | 
|---|
| 140 | 
function m_close($dbh) { | 
|---|
| 141 | 
    return null; | 
|---|
| 142 | 
    } | 
|---|
| 143 | 
 | 
|---|
| 144 | 
 | 
|---|
| 145 | 
function m_query($dbh, $query, $errmessage) { | 
|---|
| 146 | 
    try { | 
|---|
| 147 | 
        $rtn = $dbh->query($query); | 
|---|
| 148 | 
        return($rtn); | 
|---|
| 149 | 
    } catch (PDOException $e) { | 
|---|
| 150 | 
             | 
|---|
| 151 | 
            $msg = $errmessage . "<br>\n" . | 
|---|
| 152 | 
            $e->getMessage() . "<br>\n" . | 
|---|
| 153 | 
            var_export($e->errorInfo, true) . "<br>\n" . | 
|---|
| 154 | 
                   "<small><code>" . htmlspecialchars($query) . | 
|---|
| 155 | 
                   "</code></small>\n"; | 
|---|
| 156 | 
 | 
|---|
| 157 | 
$dbh = null; | 
|---|
| 158 | 
die_exit($msg); | 
|---|
| 159 | 
 | 
|---|
| 160 | 
 | 
|---|
| 161 | 
 | 
|---|
| 162 | 
function sql_query($dbh, $query, $errmessage,$paramarray=null) { | 
|---|
| 163 | 
    try { | 
|---|
| 164 | 
        $rtn = $dbh->prepare("$query"); | 
|---|
| 165 | 
        $rtn->execute($paramarray); | 
|---|
| 166 | 
        return($rtn); | 
|---|
| 167 | 
    } catch (PDOException $e) { | 
|---|
| 168 | 
             | 
|---|
| 169 | 
            $msg = $errmessage . "<br>\n" . | 
|---|
| 170 | 
            $e->getMessage() . "<br>\n" . | 
|---|
| 171 | 
            var_export($e->errorInfo, true) . "<br>\n" . | 
|---|
| 172 | 
                   "<small><code>" . htmlspecialchars($query) . | 
|---|
| 173 | 
                   "</code></small>\n"; | 
|---|
| 174 | 
 | 
|---|
| 175 | 
$dbh = null; | 
|---|
| 176 | 
die_exit($msg); | 
|---|
| 177 | 
 | 
|---|
| 178 | 
 | 
|---|
| 179 | 
 | 
|---|
| 180 | 
 | 
|---|
| 181 | 
function m_showtable($rs) { | 
|---|
| 182 | 
 | 
|---|
| 183 | 
$maxrows = 0; | 
|---|
| 184 | 
 | 
|---|
| 185 | 
$rowdata = $rs->fetch(); | 
|---|
| 186 | 
$rowdata) { | 
|---|
| 187 | 
"<p class=\"msg\">データが存在しません</p>\n"); | 
|---|
| 188 | 
0; | 
|---|
| 189 | 
 | 
|---|
| 190 | 
 | 
|---|
| 191 | 
 | 
|---|
| 192 | 
$maxcols = $rs->columnCount(); | 
|---|
| 193 | 
?> | 
|---|
| 194 | 
<table class="list" summary="データ検索結果を表示" border="1"> | 
|---|
| 195 | 
    <thead> | 
|---|
| 196 | 
        <tr> | 
|---|
| 197 | 
            <?php | 
|---|
| 198 | 
                 | 
|---|
| 199 | 
                for ($col = 1; $col < $maxcols; $col++) { | 
|---|
| 200 | 
                     | 
|---|
| 201 | 
             $meta = $rs->getColumnMeta($col); | 
|---|
| 202 | 
             $f_name = htmlspecialchars($meta["name"]); | 
|---|
| 203 | 
                    echo("<th abbr=\"$f_name\">$f_name</th>\n"); | 
|---|
| 204 | 
                } | 
|---|
| 205 | 
            ?> | 
|---|
| 206 | 
        </tr> | 
|---|
| 207 | 
    </thead> | 
|---|
| 208 | 
    <tbody> | 
|---|
| 209 | 
        <?php | 
|---|
| 210 | 
             | 
|---|
| 211 | 
          do { | 
|---|
| 212 | 
              $maxrows++; | 
|---|
| 213 | 
 | 
|---|
| 214 | 
                echo("<tr>\n"); | 
|---|
| 215 | 
                 | 
|---|
| 216 | 
                echo("<td><a href=\"edit.php?q_code=" . | 
|---|
| 217 | 
                     urlencode($rowdata[0]) . "\">" . | 
|---|
| 218 | 
                     htmlspecialchars($rowdata[1]) . "</a></td>\n"); | 
|---|
| 219 | 
                for ($col = 2; $col < $maxcols; $col++) {  | 
|---|
| 220 | 
                    echo("<td>".htmlspecialchars($rowdata[$col])."<br></td>\n"); | 
|---|
| 221 | 
                } | 
|---|
| 222 | 
                echo("</tr>\n"); | 
|---|
| 223 | 
          } while ($rowdata = $rs->fetch()); | 
|---|
| 224 | 
        ?> | 
|---|
| 225 | 
    </tbody> | 
|---|
| 226 | 
</table> | 
|---|
| 227 | 
        <?php | 
|---|
| 228 | 
        return $maxrows; | 
|---|
| 229 | 
    } | 
|---|
| 230 | 
 | 
|---|
| 231 | 
 | 
|---|
| 232 | 
function m_viewdata($dbh, $code) { | 
|---|
| 233 | 
 | 
|---|
| 234 | 
 | 
|---|
| 235 | 
} | 
|---|
| 236 | 
 | 
|---|
| 237 | 
 | 
|---|
| 238 | 
printhtmlpageheader(){ | 
|---|
| 239 | 
 | 
|---|
| 240 | 
$useenvironmentpolicy; | 
|---|
| 241 | 
 | 
|---|
| 242 | 
$serveruri = getserveruri(); | 
|---|
| 243 | 
$username = $_SERVER['PHP_AUTH_USER']; | 
|---|
| 244 | 
 | 
|---|
| 245 | 
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</A>[<a href=\"itpc://$serveruri/folcast.php\">iTunesに登録</a>] | "; | 
|---|
| 246 | 
if ($useenvironmentpolicy == 1){ | 
|---|
| 247 | 
    print "【 $username 】"; | 
|---|
| 248 | 
} | 
|---|
| 249 | 
 | 
|---|
| 250 | 
print "</font></p>\n"; | 
|---|
| 251 | 
 | 
|---|
| 252 | 
} | 
|---|
| 253 | 
 | 
|---|
| 254 | 
 | 
|---|
| 255 | 
function renderepgstation($con,$stationname,$start){  | 
|---|
| 256 | 
 | 
|---|
| 257 | 
$now = date("YmdHi"); | 
|---|
| 258 | 
$today = date("Ymd");    | 
|---|
| 259 | 
$tomorrow = date ("Ymd",mktime(0, 0, 0, date("m")  , date("d")+1, date("Y"))); | 
|---|
| 260 | 
 | 
|---|
| 261 | 
 | 
|---|
| 262 | 
 | 
|---|
| 263 | 
$epgstart = $start ; | 
|---|
| 264 | 
 | 
|---|
| 265 | 
$epgend = calcendtime($start , (8*60)); | 
|---|
| 266 | 
$query = " | 
|---|
| 267 | 
SELECT startdatetime , enddatetime , lengthmin , epgtitle , epgdesc , epgcategory  ,ontvchannel  ,epgid  | 
|---|
| 268 | 
FROM foltia_epg  | 
|---|
| 269 | 
WHERE foltia_epg.ontvchannel = '$stationname' AND  | 
|---|
| 270 | 
enddatetime  > $epgstart  AND  | 
|---|
| 271 | 
startdatetime  < $epgend   | 
|---|
| 272 | 
ORDER BY foltia_epg.startdatetime  ASC | 
|---|
| 273 | 
    "; | 
|---|
| 274 | 
    $rs = m_query($con, $query, "DBクエリに失敗しました"); | 
|---|
| 275 | 
    $rowdata = $rs->fetch(); | 
|---|
| 276 | 
    if (! $rowdata) { | 
|---|
| 277 | 
        print("番組データがありません<BR>");             | 
|---|
| 278 | 
}else{ | 
|---|
| 279 | 
print "<table width=\"100%\"  border=\"0\">\n"; | 
|---|
| 280 | 
 | 
|---|
| 281 | 
 | 
|---|
| 282 | 
do { | 
|---|
| 283 | 
$printstarttime = substr($rowdata[0],8,2) . ":" .  substr($rowdata[0],10,2); | 
|---|
| 284 | 
$tdclass = "t".substr($rowdata[0],8,2) .  substr($rowdata[0],10,2); | 
|---|
| 285 | 
$title = htmlspecialchars($rowdata[3]); | 
|---|
| 286 | 
$title = z2h($title); | 
|---|
| 287 | 
$desc = htmlspecialchars($rowdata[4]); | 
|---|
| 288 | 
$desc = z2h($desc); | 
|---|
| 289 | 
$height =  htmlspecialchars($rowdata[2]) * 3; | 
|---|
| 290 | 
$epgid =  htmlspecialchars($rowdata[7]); | 
|---|
| 291 | 
 | 
|---|
| 292 | 
print" | 
|---|
| 293 | 
      <tr> | 
|---|
| 294 | 
        <td height = \"$height\" >$printstarttime  <A HREF=\"./reserveepg.php?epgid=$epgid\">$title</A> $desc <!-- $rowdata[0] - $rowdata[1] --></td> | 
|---|
| 295 | 
      </tr> | 
|---|
| 296 | 
"; | 
|---|
| 297 | 
 | 
|---|
| 298 | 
 | 
|---|
| 299 | 
 | 
|---|
| 300 | 
 | 
|---|
| 301 | 
} while ($rowdata = $rs->fetch()); | 
|---|
| 302 | 
 | 
|---|
| 303 | 
print "</table>\n"; | 
|---|
| 304 | 
 | 
|---|
| 305 | 
} | 
|---|
| 306 | 
} | 
|---|
| 307 | 
 | 
|---|
| 308 | 
function calcendtime($start,$lengthmin){ | 
|---|
| 309 | 
$startyear =   substr($start,0,4); | 
|---|
| 310 | 
$startmonth =   substr($start,4,2); | 
|---|
| 311 | 
$startday =   substr($start,6,2); | 
|---|
| 312 | 
$starthour =   substr($start,8,2); | 
|---|
| 313 | 
$startmin =   substr($start,10,2); | 
|---|
| 314 | 
 | 
|---|
| 315 | 
$endtime = date ("YmdHi",mktime($starthour  , $startmin + $lengthmin , 0, $startmonth  , $startday, $startyear)); | 
|---|
| 316 | 
 | 
|---|
| 317 | 
return ($endtime ); | 
|---|
| 318 | 
} | 
|---|
| 319 | 
 | 
|---|
| 320 | 
 | 
|---|
| 321 | 
function z2h($string){  | 
|---|
| 322 | 
    $stringh = mb_convert_kana($string, "a", "EUC-JP"); | 
|---|
| 323 | 
 return ($stringh ); | 
|---|
| 324 | 
} | 
|---|
| 325 | 
 | 
|---|
| 326 | 
function foldate2rfc822($start){ | 
|---|
| 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 | 
    $rfc822 = date ("r",mktime($starthour  , $startmin , 0, $startmonth  , $startday, $startyear)); | 
|---|
| 334 | 
     | 
|---|
| 335 | 
    return ($rfc822); | 
|---|
| 336 | 
} | 
|---|
| 337 | 
 | 
|---|
| 338 | 
function foldate2print($start){ | 
|---|
| 339 | 
    $startyear =   substr($start,0,4); | 
|---|
| 340 | 
    $startmonth =   substr($start,4,2); | 
|---|
| 341 | 
    $startday =   substr($start,6,2); | 
|---|
| 342 | 
    $starthour =   substr($start,8,2); | 
|---|
| 343 | 
    $startmin =   substr($start,10,2); | 
|---|
| 344 | 
 | 
|---|
| 345 | 
    $printabledate = date ("Y/m/d H:i",mktime($starthour  , $startmin , 0, $startmonth  , $startday, $startyear));     | 
|---|
| 346 | 
    return ($printabledate); | 
|---|
| 347 | 
} | 
|---|
| 348 | 
 | 
|---|
| 349 | 
function getserveruri(){ | 
|---|
| 350 | 
 | 
|---|
| 351 | 
//リンクURI組み立て | 
|---|
| 352 | 
$sv6 = $_SERVER['SCRIPT_NAME']; | 
|---|
| 353 | 
$sv8 = $_SERVER['SERVER_NAME']; | 
|---|
| 354 | 
$sv9 = $_SERVER['SERVER_PORT']; | 
|---|
| 355 | 
if ($sv9 == 80){ | 
|---|
| 356 | 
    $port = ""; | 
|---|
| 357 | 
}else{ | 
|---|
| 358 | 
    $port = ":$sv9"; | 
|---|
| 359 | 
} | 
|---|
| 360 | 
$a = split("/", $sv6); | 
|---|
| 361 | 
array_pop($a); | 
|---|
| 362 | 
 | 
|---|
| 363 | 
$scriptpath = implode("/", $a); | 
|---|
| 364 | 
 | 
|---|
| 365 | 
$serveruri = "$sv8$port$scriptpath"; | 
|---|
| 366 | 
return ($serveruri ); | 
|---|
| 367 | 
} | 
|---|
| 368 | 
 | 
|---|
| 369 | 
 | 
|---|
| 370 | 
function getserverfqdn(){ | 
|---|
| 371 | 
 | 
|---|
| 372 | 
//リンクURI組み立て | 
|---|
| 373 | 
$sv6 = $_SERVER['SCRIPT_NAME']; | 
|---|
| 374 | 
$sv8 = $_SERVER['SERVER_NAME']; | 
|---|
| 375 | 
$sv9 = $_SERVER['SERVER_PORT']; | 
|---|
| 376 | 
if ($sv9 == 80){ | 
|---|
| 377 | 
    $port = ""; | 
|---|
| 378 | 
}else{ | 
|---|
| 379 | 
    $port = ":$sv9"; | 
|---|
| 380 | 
} | 
|---|
| 381 | 
$a = split("/", $sv6); | 
|---|
| 382 | 
array_pop($a); | 
|---|
| 383 | 
 | 
|---|
| 384 | 
$scriptpath = implode("/", $a); | 
|---|
| 385 | 
 | 
|---|
| 386 | 
$serveruri = "$sv8$port"; | 
|---|
| 387 | 
return ($serveruri ); | 
|---|
| 388 | 
} | 
|---|
| 389 | 
 | 
|---|
| 390 | 
 | 
|---|
| 391 | 
function printdiskusage(){ | 
|---|
| 392 | 
list (, $all, $use , $free, $usepercent) =  getdiskusage(); | 
|---|
| 393 | 
 | 
|---|
| 394 | 
print " | 
|---|
| 395 | 
<div style=\"width:100%;border:1px solid black;text-align:left;\"><span style=\"float:right;\">$free</span> | 
|---|
| 396 | 
<div style=\"width:$usepercent;border:1px solid black;background:white;\">$use/$all($usepercent)</div> | 
|---|
| 397 | 
</div> | 
|---|
| 398 | 
"; | 
|---|
| 399 | 
 | 
|---|
| 400 | 
} | 
|---|
| 401 | 
 | 
|---|
| 402 | 
 | 
|---|
| 403 | 
function getdiskusage(){ | 
|---|
| 404 | 
 | 
|---|
| 405 | 
global $recfolderpath,$recfolderpath; | 
|---|
| 406 | 
 | 
|---|
| 407 | 
 | 
|---|
| 408 | 
 | 
|---|
| 409 | 
exec ( "df -hP  $recfolderpath", $hdfreearea); | 
|---|
| 410 | 
$freearea = preg_split ("/[\s,]+/", $hdfreearea[count($hdfreearea)-1]); | 
|---|
| 411 | 
 | 
|---|
| 412 | 
$freearea; | 
|---|
| 413 | 
 | 
|---|
| 414 | 
 | 
|---|
| 415 | 
 | 
|---|
| 416 | 
 | 
|---|
| 417 | 
function printtrcnprocesses(){ | 
|---|
| 418 | 
 | 
|---|
| 419 | 
$ffmpegprocesses = `ps ax | grep ffmpeg | grep -v grep |  wc -l `; | 
|---|
| 420 | 
$uptime = exec('uptime'); | 
|---|
| 421 | 
 | 
|---|
| 422 | 
print "<div style=\"text-align:left;\">"; | 
|---|
| 423 | 
print "$uptime<br>\n"; | 
|---|
| 424 | 
print "トラコン稼働数:$ffmpegprocesses<br>\n"; | 
|---|
| 425 | 
print "</div>"; | 
|---|
| 426 | 
 | 
|---|
| 427 | 
} | 
|---|
| 428 | 
 | 
|---|
| 429 | 
 | 
|---|
| 430 | 
function warndiskfreearea(){ | 
|---|
| 431 | 
 | 
|---|
| 432 | 
global $demomode; | 
|---|
| 433 | 
 | 
|---|
| 434 | 
if ($demomode){ | 
|---|
| 435 | 
print "<!-- demo mode -->"; | 
|---|
| 436 | 
}else{ | 
|---|
| 437 | 
 | 
|---|
| 438 | 
global $recfolderpath,$hdfreearea ; | 
|---|
| 439 | 
 | 
|---|
| 440 | 
    exec ( "df   $recfolderpath | grep $recfolderpath", $hdfreearea); | 
|---|
| 441 | 
    $freearea = preg_split ("/[\s,]+/", $hdfreearea[0]); | 
|---|
| 442 | 
$freebytes = $freearea[3]; | 
|---|
| 443 | 
if ($freebytes == "" ){ | 
|---|
| 444 | 
 | 
|---|
| 445 | 
 | 
|---|
| 446 | 
}elseif($freebytes > 1024*1024*100 ){ | 
|---|
| 447 | 
//なにもしない | 
|---|
| 448 | 
print "<style type=\"text/css\"><!-- --></style>"; | 
|---|
| 449 | 
}elseif($freebytes > 1024*1024*50 ){ | 
|---|
| 450 | 
print "<style type=\"text/css\"><!-- | 
|---|
| 451 | 
    body { | 
|---|
| 452 | 
    background-color: #CCCC99; | 
|---|
| 453 | 
     } | 
|---|
| 454 | 
--> | 
|---|
| 455 | 
</style> | 
|---|
| 456 | 
"; | 
|---|
| 457 | 
}elseif($freebytes > 1024*1024*30 ){ | 
|---|
| 458 | 
print "<style type=\"text/css\"><!-- | 
|---|
| 459 | 
    body { | 
|---|
| 460 | 
    background-color:#CC6666; | 
|---|
| 461 | 
     } | 
|---|
| 462 | 
--> | 
|---|
| 463 | 
</style> | 
|---|
| 464 | 
"; | 
|---|
| 465 | 
}elseif($freebytes > 0 ){ | 
|---|
| 466 | 
print "<style type=\"text/css\"><!-- | 
|---|
| 467 | 
    body { | 
|---|
| 468 | 
    background-color:#FF0000; | 
|---|
| 469 | 
     } | 
|---|
| 470 | 
--> | 
|---|
| 471 | 
</style> | 
|---|
| 472 | 
"; | 
|---|
| 473 | 
}else{  | 
|---|
| 474 | 
print "<style type=\"text/css\"><!-- | 
|---|
| 475 | 
    body { | 
|---|
| 476 | 
    background-color:#000000; | 
|---|
| 477 | 
     } | 
|---|
| 478 | 
--> | 
|---|
| 479 | 
</style> | 
|---|
| 480 | 
"; | 
|---|
| 481 | 
} | 
|---|
| 482 | 
 | 
|---|
| 483 | 
} | 
|---|
| 484 | 
 | 
|---|
| 485 | 
} | 
|---|
| 486 | 
 | 
|---|
| 487 | 
 | 
|---|
| 488 | 
 | 
|---|
| 489 | 
function foldatevalidation($foldate){ | 
|---|
| 490 | 
 | 
|---|
| 491 | 
if (strlen($foldate) == 12 ){ | 
|---|
| 492 | 
 | 
|---|
| 493 | 
    $startyear =   substr($foldate,0,4); | 
|---|
| 494 | 
    $startmonth =   substr($foldate,4,2); | 
|---|
| 495 | 
    $startday =   substr($foldate,6,2); | 
|---|
| 496 | 
    $starthour =   substr($foldate,8,2); | 
|---|
| 497 | 
    $startmin =   substr($foldate,10,2); | 
|---|
| 498 | 
 | 
|---|
| 499 | 
    $startepoch = date ("U",mktime($starthour  , $startmin , 0, $startmonth  , $startday, $startyear));     | 
|---|
| 500 | 
    $nowe = time(); | 
|---|
| 501 | 
    if ($startepoch > $nowe){ | 
|---|
| 502 | 
     | 
|---|
| 503 | 
        return TRUE; | 
|---|
| 504 | 
    }else{ | 
|---|
| 505 | 
        return FALSE; | 
|---|
| 506 | 
    }     | 
|---|
| 507 | 
}else{ | 
|---|
| 508 | 
    return FALSE; | 
|---|
| 509 | 
} | 
|---|
| 510 | 
 | 
|---|
| 511 | 
} | 
|---|
| 512 | 
 | 
|---|
| 513 | 
 | 
|---|
| 514 | 
 | 
|---|
| 515 | 
function login($con,$name,$passwd){ | 
|---|
| 516 | 
global $environmentpolicytoken; | 
|---|
| 517 | 
 | 
|---|
| 518 | 
 | 
|---|
| 519 | 
if (((mb_ereg('[^0-9a-zA-Z]', $name)) ||(mb_ereg('[^0-9a-zA-Z]', $passwd) ))){ | 
|---|
| 520 | 
 | 
|---|
| 521 | 
 | 
|---|
| 522 | 
 | 
|---|
| 523 | 
redirectlogin(); | 
|---|
| 524 | 
 | 
|---|
| 525 | 
 | 
|---|
| 526 | 
 | 
|---|
| 527 | 
 | 
|---|
| 528 | 
escape_string($name); | 
|---|
| 529 | 
escape_string($passwd); | 
|---|
| 530 | 
 | 
|---|
| 531 | 
$query = " | 
|---|
| 532 | 
SELECT memberid ,userclass,name,passwd1  | 
|---|
| 533 | 
FROM foltia_envpolicy  | 
|---|
| 534 | 
WHERE foltia_envpolicy.name  = '$name'   | 
|---|
| 535 | 
    "; | 
|---|
| 536 | 
    $useraccount = m_query($con, $query, "DBクエリに失敗しました"); | 
|---|
| 537 | 
        $rowdata = $useraccount->fetch(); | 
|---|
| 538 | 
        if (! $rowdata) { | 
|---|
| 539 | 
            header("HTTP/1.0 401 Unauthorized"); | 
|---|
| 540 | 
            redirectlogin(); | 
|---|
| 541 | 
        } | 
|---|
| 542 | 
     | 
|---|
| 543 | 
        $memberid = $rowdata[0]; | 
|---|
| 544 | 
        $userclass = $rowdata[1]; | 
|---|
| 545 | 
        $username =  $rowdata[2]; | 
|---|
| 546 | 
        $dbpasswd = $rowdata[3]; | 
|---|
| 547 | 
 | 
|---|
| 548 | 
        $rowdata = $useraccount->fetch(); | 
|---|
| 549 | 
        if ($rowdata) { | 
|---|
| 550 | 
        header("HTTP/1.0 401 Unauthorized"); | 
|---|
| 551 | 
        redirectlogin(); | 
|---|
| 552 | 
        } | 
|---|
| 553 | 
 | 
|---|
| 554 | 
 | 
|---|
| 555 | 
if ($userclass == 0){ | 
|---|
| 556 | 
$dbpasswd = "$dbpasswd"; | 
|---|
| 557 | 
}else{ | 
|---|
| 558 | 
 | 
|---|
| 559 | 
$dbpasswd = "$dbpasswd"."$environmentpolicytoken"; | 
|---|
| 560 | 
} | 
|---|
| 561 | 
 | 
|---|
| 562 | 
if ($passwd == $dbpasswd) { | 
|---|
| 563 | 
 | 
|---|
| 564 | 
}else{ | 
|---|
| 565 | 
 | 
|---|
| 566 | 
header("HTTP/1.0 401 Unauthorized"); | 
|---|
| 567 | 
 | 
|---|
| 568 | 
redirectlogin(); | 
|---|
| 569 | 
 | 
|---|
| 570 | 
 | 
|---|
| 571 | 
} | 
|---|
| 572 | 
 | 
|---|
| 573 | 
 | 
|---|
| 574 | 
 | 
|---|
| 575 | 
 | 
|---|
| 576 | 
function redirectlogin(){ | 
|---|
| 577 | 
global $environmentpolicytoken; | 
|---|
| 578 | 
 | 
|---|
| 579 | 
print "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\n"; | 
|---|
| 580 | 
print "<html><head>\n"; | 
|---|
| 581 | 
print "<title>foltia:Invalid login</title>\n"; | 
|---|
| 582 | 
print "</head><body>\n"; | 
|---|
| 583 | 
print "<h1>Invalid login</h1>"; | 
|---|
| 584 | 
print "<p>foltiaヘのアクセスにはログインが必要です。再ログインはリロードやブラウザ再起動で、新規アカウント登録は<a href=\"./accountregist.php\">こちらから。</a></p>"; | 
|---|
| 585 | 
if ($environmentpolicytoken == ""){ | 
|---|
| 586 | 
}else{ | 
|---|
| 587 | 
    print "<p>突然この画面が表示された場合にはセキュリティコードが変更されたかも知れません。</p>"; | 
|---|
| 588 | 
} | 
|---|
| 589 | 
print "</p><hr>\n"; | 
|---|
| 590 | 
print "<address>foltia by DCC-JPL Japan/foltia Project.  <a href = \"http://www.dcc-jpl.com/soft/foltia/\">http://www.dcc-jpl.com/soft/foltia/</a></address>\n"; | 
|---|
| 591 | 
print "</body></html>\n"; | 
|---|
| 592 | 
 | 
|---|
| 593 | 
 | 
|---|
| 594 | 
 | 
|---|
| 595 | 
exit; | 
|---|
| 596 | 
} | 
|---|
| 597 | 
 | 
|---|
| 598 | 
function getuserclass($con){ | 
|---|
| 599 | 
global $useenvironmentpolicy; | 
|---|
| 600 | 
$username = $_SERVER['PHP_AUTH_USER']; | 
|---|
| 601 | 
 | 
|---|
| 602 | 
if ($useenvironmentpolicy == 1){ | 
|---|
| 603 | 
$query = " | 
|---|
| 604 | 
SELECT memberid ,userclass,name,passwd1  | 
|---|
| 605 | 
FROM foltia_envpolicy  | 
|---|
| 606 | 
WHERE foltia_envpolicy.name  = '$username'   | 
|---|
| 607 | 
    "; | 
|---|
| 608 | 
        $useraccount = m_query($con, $query, "DBクエリに失敗しました"); | 
|---|
| 609 | 
        $rowdata = $useraccount->fetch(); | 
|---|
| 610 | 
        if (! $rowdata) { | 
|---|
| 611 | 
            return (99); | 
|---|
| 612 | 
        } | 
|---|
| 613 | 
     | 
|---|
| 614 | 
        $userclass = $rowdata[1]; | 
|---|
| 615 | 
 | 
|---|
| 616 | 
        $rowdata = $useraccount->fetch(); | 
|---|
| 617 | 
        if ($rowdata) { | 
|---|
| 618 | 
            return (99); | 
|---|
| 619 | 
        } | 
|---|
| 620 | 
 | 
|---|
| 621 | 
        return ($userclass); | 
|---|
| 622 | 
     | 
|---|
| 623 | 
}else{ | 
|---|
| 624 | 
    return (0); | 
|---|
| 625 | 
} | 
|---|
| 626 | 
} | 
|---|
| 627 | 
 | 
|---|
| 628 | 
 | 
|---|
| 629 | 
 | 
|---|
| 630 | 
function getmymemberid($con){ | 
|---|
| 631 | 
global $useenvironmentpolicy; | 
|---|
| 632 | 
$username = $_SERVER['PHP_AUTH_USER']; | 
|---|
| 633 | 
 | 
|---|
| 634 | 
if ($useenvironmentpolicy == 1){ | 
|---|
| 635 | 
$query = " | 
|---|
| 636 | 
SELECT memberid ,userclass,name,passwd1  | 
|---|
| 637 | 
FROM foltia_envpolicy  | 
|---|
| 638 | 
WHERE foltia_envpolicy.name  = '$username'   | 
|---|
| 639 | 
    "; | 
|---|
| 640 | 
        $useraccount = m_query($con, $query, "DBクエリに失敗しました"); | 
|---|
| 641 | 
        $rowdata = $useraccount->fetch(); | 
|---|
| 642 | 
        if (! $rowdata) { | 
|---|
| 643 | 
    return (-1); | 
|---|
| 644 | 
        } | 
|---|
| 645 | 
 | 
|---|
| 646 | 
        $memberid = $rowdata[0]; | 
|---|
| 647 | 
 | 
|---|
| 648 | 
        $rowdata = $useraccount->fetch(); | 
|---|
| 649 | 
        if ($rowdata) { | 
|---|
| 650 | 
            return (-1); | 
|---|
| 651 | 
        } | 
|---|
| 652 | 
 | 
|---|
| 653 | 
        return ($memberid); | 
|---|
| 654 | 
     | 
|---|
| 655 | 
}else{ | 
|---|
| 656 | 
    return (0); | 
|---|
| 657 | 
} | 
|---|
| 658 | 
} | 
|---|
| 659 | 
 | 
|---|
| 660 | 
 | 
|---|
| 661 | 
function getmemberid2name($con,$memberid){ | 
|---|
| 662 | 
global $useenvironmentpolicy; | 
|---|
| 663 | 
 | 
|---|
| 664 | 
 | 
|---|
| 665 | 
if ($useenvironmentpolicy == 1){ | 
|---|
| 666 | 
$query = " | 
|---|
| 667 | 
SELECT memberid ,userclass,name,passwd1  | 
|---|
| 668 | 
FROM foltia_envpolicy  | 
|---|
| 669 | 
WHERE foltia_envpolicy.memberid  = '$memberid'   | 
|---|
| 670 | 
    "; | 
|---|
| 671 | 
        $useraccount = m_query($con, $query, "DBクエリに失敗しました"); | 
|---|
| 672 | 
        $rowdata = $useraccount->fetch(); | 
|---|
| 673 | 
        if (! $rowdata) { | 
|---|
| 674 | 
    return (""); | 
|---|
| 675 | 
        } | 
|---|
| 676 | 
     | 
|---|
| 677 | 
        $name = $rowdata[2]; | 
|---|
| 678 | 
 | 
|---|
| 679 | 
        $rowdata = $useraccount->fetch(); | 
|---|
| 680 | 
        if ($rowdata) { | 
|---|
| 681 | 
    return (""); | 
|---|
| 682 | 
        } | 
|---|
| 683 | 
 | 
|---|
| 684 | 
        return ($name); | 
|---|
| 685 | 
 | 
|---|
| 686 | 
    }else{ | 
|---|
| 687 | 
        return (""); | 
|---|
| 688 | 
    } | 
|---|
| 689 | 
 | 
|---|
| 690 | 
} | 
|---|
| 691 | 
 | 
|---|
| 692 | 
 | 
|---|
| 693 | 
 | 
|---|
| 694 | 
function number_page($p,$lim){ | 
|---|
| 695 | 
 | 
|---|
| 696 | 
 | 
|---|
| 697 | 
 | 
|---|
| 698 | 
 | 
|---|
| 699 | 
 | 
|---|
| 700 | 
 | 
|---|
| 701 | 
 | 
|---|
| 702 | 
 | 
|---|
| 703 | 
 | 
|---|
| 704 | 
if($p == 0){ | 
|---|
| 705 | 
$p2 = 2;         | 
|---|
| 706 | 
}else{ | 
|---|
| 707 | 
$p2 = $p;        | 
|---|
| 708 | 
$p2++; | 
|---|
| 709 | 
 | 
|---|
| 710 | 
 | 
|---|
| 711 | 
$p < 1){ | 
|---|
| 712 | 
$p = 1; | 
|---|
| 713 | 
 | 
|---|
| 714 | 
 | 
|---|
| 715 | 
$st = ($p -1) * $lim; | 
|---|
| 716 | 
 | 
|---|
| 717 | 
 | 
|---|
| 718 | 
return array($st,$p,$p2); | 
|---|
| 719 | 
 | 
|---|
| 720 | 
 | 
|---|
| 721 | 
 | 
|---|
| 722 | 
function page_display($query_st,$p,$p2,$lim,$dtcnt,$mode){ | 
|---|
| 723 | 
 | 
|---|
| 724 | 
 | 
|---|
| 725 | 
 | 
|---|
| 726 | 
 | 
|---|
| 727 | 
 | 
|---|
| 728 | 
 | 
|---|
| 729 | 
 | 
|---|
| 730 | 
 | 
|---|
| 731 | 
 | 
|---|
| 732 | 
 | 
|---|
| 733 | 
 | 
|---|
| 734 | 
 | 
|---|
| 735 | 
if($query_st == ""){ | 
|---|
| 736 | 
 | 
|---|
| 737 | 
$page = ceil($dtcnt / $lim); | 
|---|
| 738 | 
 | 
|---|
| 739 | 
if($mode == ''){ | 
|---|
| 740 | 
"$p/$page";          | 
|---|
| 741 | 
} | 
|---|
| 742 | 
 | 
|---|
| 743 | 
for($i=1;$i <= $page; $i++){ | 
|---|
| 744 | 
"<a href=\"".$_SERVER["PHP_SELF"]."?p=$i\" > $i </a>"); | 
|---|
| 745 | 
 | 
|---|
| 746 | 
 | 
|---|
| 747 | 
if($page >= $p2 ){ | 
|---|
| 748 | 
"<a rel=next href=\"".$_SERVER["PHP_SELF"]."?p=$p2\" > </a>"); | 
|---|
| 749 | 
 | 
|---|
| 750 | 
 | 
|---|
| 751 | 
$query_st = $_SERVER['QUERY_STRING']; | 
|---|
| 752 | 
$page = ceil($dtcnt / $lim); | 
|---|
| 753 | 
"$p/$page"; | 
|---|
| 754 | 
 | 
|---|
| 755 | 
for($i=1;$i <= $page; $i++){ | 
|---|
| 756 | 
$query_st =  preg_replace('/p=[0-9]+&/','',$query_st);     | 
|---|
| 757 | 
print("<a href=\"".$_SERVER["PHP_SELF"]."?p=$i&$query_st\" > $i </a>"); | 
|---|
| 758 | 
 | 
|---|
| 759 | 
 | 
|---|
| 760 | 
if($page >= $p2 ){ | 
|---|
| 761 | 
$query_st =  preg_replace('/p=[0-9]+&/','',$query_st); | 
|---|
| 762 | 
"<a rel=next href=\"".$_SERVER["PHP_SELF"]."?p=$p2&$query_st\" > </a>"); | 
|---|
| 763 | 
 | 
|---|
| 764 | 
 | 
|---|
| 765 | 
$p2,$page); | 
|---|
| 766 | 
 | 
|---|
| 767 | 
 | 
|---|
| 768 | 
function getnextstationid($con){ | 
|---|
| 769 | 
 | 
|---|
| 770 | 
$query2 = "SELECT max(stationid) FROM  foltia_station"; | 
|---|
| 771 | 
$rs2 = sql_query($con, $query2, "DBクエリに失敗しました"); | 
|---|
| 772 | 
$rowdata2 = $rs2->fetch(); | 
|---|
| 773 | 
if (! $rowdata2) {       | 
|---|
| 774 | 
        $sid = 1 ; | 
|---|
| 775 | 
}else{                   | 
|---|
| 776 | 
        $sid = $rowdata2[0]; | 
|---|
| 777 | 
        $sid ++ ; | 
|---|
| 778 | 
} | 
|---|
| 779 | 
return ($sid); | 
|---|
| 780 | 
} | 
|---|
| 781 | 
 | 
|---|
| 782 | 
?> | 
|---|
| 783 | 
 | 
|---|