| 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"><?= $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 |  | 
|---|
| 239 |  | 
|---|
| 240 |  | 
|---|
| 241 |  | 
|---|
| 242 |  | 
|---|
| 243 |  | 
|---|
| 244 |  | 
|---|
| 245 |  | 
|---|
| 246 |  | 
|---|
| 247 |  | 
|---|
| 248 |  | 
|---|
| 249 |  | 
|---|
| 250 |  | 
|---|
| 251 |  | 
|---|
| 252 |  | 
|---|
| 253 |  | 
|---|
| 254 |  | 
|---|
| 255 |  | 
|---|
| 256 |  | 
|---|
| 257 |  | 
|---|
| 258 |  | 
|---|
| 259 |  | 
|---|
| 260 |  | 
|---|
| 261 |  | 
|---|
| 262 |  | 
|---|
| 263 |  | 
|---|
| 264 |  | 
|---|
| 265 |  | 
|---|
| 266 |  | 
|---|
| 267 |  | 
|---|
| 268 |  | 
|---|
| 269 |  | 
|---|
| 270 |  | 
|---|
| 271 |  | 
|---|
| 272 |  | 
|---|
| 273 |  | 
|---|
| 274 |  | 
|---|
| 275 |  | 
|---|
| 276 | } | 
|---|
| 277 |  | 
|---|
| 278 |  | 
|---|
| 279 | printhtmlpageheader(){ | 
|---|
| 280 |  | 
|---|
| 281 | $useenvironmentpolicy; | 
|---|
| 282 |  | 
|---|
| 283 | $serveruri = getserveruri(); | 
|---|
| 284 | $username = $_SERVER['PHP_AUTH_USER']; | 
|---|
| 285 |  | 
|---|
| 286 | 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>] | "; | 
|---|
| 287 | if ($useenvironmentpolicy == 1){ | 
|---|
| 288 | print "【 $username 】"; | 
|---|
| 289 | } | 
|---|
| 290 |  | 
|---|
| 291 | print "</font></p>\n"; | 
|---|
| 292 |  | 
|---|
| 293 | } | 
|---|
| 294 |  | 
|---|
| 295 |  | 
|---|
| 296 | function renderepgstation($con,$stationname,$start){ | 
|---|
| 297 |  | 
|---|
| 298 | $now = date("YmdHi"); | 
|---|
| 299 | $today = date("Ymd"); | 
|---|
| 300 | $tomorrow = date ("Ymd",mktime(0, 0, 0, date("m")  , date("d")+1, date("Y"))); | 
|---|
| 301 |  | 
|---|
| 302 |  | 
|---|
| 303 |  | 
|---|
| 304 | $epgstart = $start ; | 
|---|
| 305 |  | 
|---|
| 306 | $epgend = calcendtime($start , (8*60)); | 
|---|
| 307 | $query = " | 
|---|
| 308 | SELECT startdatetime , enddatetime , lengthmin , epgtitle , epgdesc , epgcategory  ,ontvchannel  ,epgid | 
|---|
| 309 | FROM foltia_epg | 
|---|
| 310 | WHERE foltia_epg.ontvchannel = '$stationname' AND | 
|---|
| 311 | enddatetime  > $epgstart  AND | 
|---|
| 312 | startdatetime  < $epgend | 
|---|
| 313 | ORDER BY foltia_epg.startdatetime  ASC | 
|---|
| 314 | "; | 
|---|
| 315 | $rs = m_query($con, $query, "DBクエリに失敗しました"); | 
|---|
| 316 | $rowdata = $rs->fetch(); | 
|---|
| 317 | if (! $rowdata) { | 
|---|
| 318 | print("番組データがありません<BR>"); | 
|---|
| 319 | }else{ | 
|---|
| 320 | print "<table width=\"100%\"  border=\"0\">\n"; | 
|---|
| 321 |  | 
|---|
| 322 |  | 
|---|
| 323 | do { | 
|---|
| 324 | $printstarttime = substr($rowdata[0],8,2) . ":" .  substr($rowdata[0],10,2); | 
|---|
| 325 | $tdclass = "t".substr($rowdata[0],8,2) .  substr($rowdata[0],10,2); | 
|---|
| 326 | $title = htmlspecialchars($rowdata[3]); | 
|---|
| 327 | $title = z2h($title); | 
|---|
| 328 | $desc = htmlspecialchars($rowdata[4]); | 
|---|
| 329 | $desc = z2h($desc); | 
|---|
| 330 | $height =  htmlspecialchars($rowdata[2]) * 3; | 
|---|
| 331 | $epgid =  htmlspecialchars($rowdata[7]); | 
|---|
| 332 |  | 
|---|
| 333 | print" | 
|---|
| 334 | <tr> | 
|---|
| 335 | <td height = \"$height\" >$printstarttime  <A HREF=\"./reserveepg.php?epgid=$epgid\">$title</A> $desc <!-- $rowdata[0] - $rowdata[1] --></td> | 
|---|
| 336 | </tr> | 
|---|
| 337 | "; | 
|---|
| 338 |  | 
|---|
| 339 |  | 
|---|
| 340 |  | 
|---|
| 341 |  | 
|---|
| 342 | } while ($rowdata = $rs->fetch()); | 
|---|
| 343 |  | 
|---|
| 344 | print "</table>\n"; | 
|---|
| 345 |  | 
|---|
| 346 | } | 
|---|
| 347 | } | 
|---|
| 348 |  | 
|---|
| 349 | function calcendtime($start,$lengthmin){ | 
|---|
| 350 | $startyear =   substr($start,0,4); | 
|---|
| 351 | $startmonth =   substr($start,4,2); | 
|---|
| 352 | $startday =   substr($start,6,2); | 
|---|
| 353 | $starthour =   substr($start,8,2); | 
|---|
| 354 | $startmin =   substr($start,10,2); | 
|---|
| 355 |  | 
|---|
| 356 | $endtime = date ("YmdHi",mktime($starthour  , $startmin + $lengthmin , 0, $startmonth  , $startday, $startyear)); | 
|---|
| 357 |  | 
|---|
| 358 | return ($endtime ); | 
|---|
| 359 | } | 
|---|
| 360 |  | 
|---|
| 361 |  | 
|---|
| 362 | function z2h($string){ | 
|---|
| 363 | $stringh = mb_convert_kana($string, "a", "EUC-JP"); | 
|---|
| 364 | return ($stringh ); | 
|---|
| 365 | } | 
|---|
| 366 |  | 
|---|
| 367 | function foldate2rfc822($start){ | 
|---|
| 368 | $startyear =   substr($start,0,4); | 
|---|
| 369 | $startmonth =   substr($start,4,2); | 
|---|
| 370 | $startday =   substr($start,6,2); | 
|---|
| 371 | $starthour =   substr($start,8,2); | 
|---|
| 372 | $startmin =   substr($start,10,2); | 
|---|
| 373 |  | 
|---|
| 374 | $rfc822 = date ("r",mktime($starthour  , $startmin , 0, $startmonth  , $startday, $startyear)); | 
|---|
| 375 |  | 
|---|
| 376 | return ($rfc822); | 
|---|
| 377 | } | 
|---|
| 378 |  | 
|---|
| 379 | function foldate2print($start){ | 
|---|
| 380 | $startyear =   substr($start,0,4); | 
|---|
| 381 | $startmonth =   substr($start,4,2); | 
|---|
| 382 | $startday =   substr($start,6,2); | 
|---|
| 383 | $starthour =   substr($start,8,2); | 
|---|
| 384 | $startmin =   substr($start,10,2); | 
|---|
| 385 |  | 
|---|
| 386 | $printabledate = date ("Y/m/d H:i",mktime($starthour  , $startmin , 0, $startmonth  , $startday, $startyear)); | 
|---|
| 387 | return ($printabledate); | 
|---|
| 388 | } | 
|---|
| 389 |  | 
|---|
| 390 | function getserveruri(){ | 
|---|
| 391 |  | 
|---|
| 392 | //リンクURI組み立て | 
|---|
| 393 | $sv6 = $_SERVER['SCRIPT_NAME']; | 
|---|
| 394 | $sv8 = $_SERVER['SERVER_NAME']; | 
|---|
| 395 | $sv9 = $_SERVER['SERVER_PORT']; | 
|---|
| 396 | if ($sv9 == 80){ | 
|---|
| 397 | $port = ""; | 
|---|
| 398 | }else{ | 
|---|
| 399 | $port = ":$sv9"; | 
|---|
| 400 | } | 
|---|
| 401 | $a = split("/", $sv6); | 
|---|
| 402 | array_pop($a); | 
|---|
| 403 |  | 
|---|
| 404 | $scriptpath = implode("/", $a); | 
|---|
| 405 |  | 
|---|
| 406 | $serveruri = "$sv8$port$scriptpath"; | 
|---|
| 407 | return ($serveruri ); | 
|---|
| 408 | } | 
|---|
| 409 |  | 
|---|
| 410 |  | 
|---|
| 411 | function getserverfqdn(){ | 
|---|
| 412 |  | 
|---|
| 413 | //リンクURI組み立て | 
|---|
| 414 | $sv6 = $_SERVER['SCRIPT_NAME']; | 
|---|
| 415 | $sv8 = $_SERVER['SERVER_NAME']; | 
|---|
| 416 | $sv9 = $_SERVER['SERVER_PORT']; | 
|---|
| 417 | if ($sv9 == 80){ | 
|---|
| 418 | $port = ""; | 
|---|
| 419 | }else{ | 
|---|
| 420 | $port = ":$sv9"; | 
|---|
| 421 | } | 
|---|
| 422 | $a = split("/", $sv6); | 
|---|
| 423 | array_pop($a); | 
|---|
| 424 |  | 
|---|
| 425 | $scriptpath = implode("/", $a); | 
|---|
| 426 |  | 
|---|
| 427 | $serveruri = "$sv8$port"; | 
|---|
| 428 | return ($serveruri ); | 
|---|
| 429 | } | 
|---|
| 430 |  | 
|---|
| 431 |  | 
|---|
| 432 | function printdiskusage(){ | 
|---|
| 433 | list (, $all, $use , $free, $usepercent) =  getdiskusage(); | 
|---|
| 434 |  | 
|---|
| 435 | print " | 
|---|
| 436 | <div style=\"width:100%;border:1px solid black;text-align:left;\"><span style=\"float:right;\">$free</span> | 
|---|
| 437 | <div style=\"width:$usepercent;border:1px solid black;background:white;\">$use/$all($usepercent)</div> | 
|---|
| 438 | </div> | 
|---|
| 439 | "; | 
|---|
| 440 |  | 
|---|
| 441 | } | 
|---|
| 442 |  | 
|---|
| 443 |  | 
|---|
| 444 | function getdiskusage(){ | 
|---|
| 445 |  | 
|---|
| 446 | global $recfolderpath,$recfolderpath; | 
|---|
| 447 |  | 
|---|
| 448 |  | 
|---|
| 449 |  | 
|---|
| 450 | exec ( "df -hP  $recfolderpath", $hdfreearea); | 
|---|
| 451 | $freearea = preg_split ("/[\s,]+/", $hdfreearea[count($hdfreearea)-1]); | 
|---|
| 452 |  | 
|---|
| 453 | $freearea; | 
|---|
| 454 |  | 
|---|
| 455 |  | 
|---|
| 456 |  | 
|---|
| 457 |  | 
|---|
| 458 | function printtrcnprocesses(){ | 
|---|
| 459 |  | 
|---|
| 460 | $ffmpegprocesses = `ps ax | grep ffmpeg | grep -v grep |  wc -l `; | 
|---|
| 461 | $uptime = exec('uptime'); | 
|---|
| 462 |  | 
|---|
| 463 | print "<div style=\"text-align:left;\">"; | 
|---|
| 464 | print "$uptime<br>\n"; | 
|---|
| 465 | print "トラコン稼働数:$ffmpegprocesses<br>\n"; | 
|---|
| 466 | print "</div>"; | 
|---|
| 467 |  | 
|---|
| 468 | } | 
|---|
| 469 |  | 
|---|
| 470 |  | 
|---|
| 471 | function warndiskfreearea(){ | 
|---|
| 472 |  | 
|---|
| 473 | global $demomode; | 
|---|
| 474 |  | 
|---|
| 475 | if ($demomode){ | 
|---|
| 476 | print "<!-- demo mode -->"; | 
|---|
| 477 | }else{ | 
|---|
| 478 |  | 
|---|
| 479 | global $recfolderpath,$hdfreearea ; | 
|---|
| 480 |  | 
|---|
| 481 | exec ( "df   $recfolderpath | grep $recfolderpath", $hdfreearea); | 
|---|
| 482 | $freearea = preg_split ("/[\s,]+/", $hdfreearea[0]); | 
|---|
| 483 | $freebytes = $freearea[3]; | 
|---|
| 484 | if ($freebytes == "" ){ | 
|---|
| 485 |  | 
|---|
| 486 |  | 
|---|
| 487 | }elseif($freebytes > 1024*1024*100 ){ | 
|---|
| 488 | //なにもしない | 
|---|
| 489 | print "<style type=\"text/css\"><!-- --></style>"; | 
|---|
| 490 | }elseif($freebytes > 1024*1024*50 ){ | 
|---|
| 491 | print "<style type=\"text/css\"><!-- | 
|---|
| 492 | body { | 
|---|
| 493 | background-color: #CCCC99; | 
|---|
| 494 | } | 
|---|
| 495 | --> | 
|---|
| 496 | </style> | 
|---|
| 497 | "; | 
|---|
| 498 | }elseif($freebytes > 1024*1024*30 ){ | 
|---|
| 499 | print "<style type=\"text/css\"><!-- | 
|---|
| 500 | body { | 
|---|
| 501 | background-color:#CC6666; | 
|---|
| 502 | } | 
|---|
| 503 | --> | 
|---|
| 504 | </style> | 
|---|
| 505 | "; | 
|---|
| 506 | }elseif($freebytes > 0 ){ | 
|---|
| 507 | print "<style type=\"text/css\"><!-- | 
|---|
| 508 | body { | 
|---|
| 509 | background-color:#FF0000; | 
|---|
| 510 | } | 
|---|
| 511 | --> | 
|---|
| 512 | </style> | 
|---|
| 513 | "; | 
|---|
| 514 | }else{ | 
|---|
| 515 | print "<style type=\"text/css\"><!-- | 
|---|
| 516 | body { | 
|---|
| 517 | background-color:#000000; | 
|---|
| 518 | } | 
|---|
| 519 | --> | 
|---|
| 520 | </style> | 
|---|
| 521 | "; | 
|---|
| 522 | } | 
|---|
| 523 |  | 
|---|
| 524 | } | 
|---|
| 525 |  | 
|---|
| 526 | } | 
|---|
| 527 |  | 
|---|
| 528 |  | 
|---|
| 529 |  | 
|---|
| 530 | function foldatevalidation($foldate){ | 
|---|
| 531 |  | 
|---|
| 532 | if (strlen($foldate) == 12 ){ | 
|---|
| 533 |  | 
|---|
| 534 | $startyear =   substr($foldate,0,4); | 
|---|
| 535 | $startmonth =   substr($foldate,4,2); | 
|---|
| 536 | $startday =   substr($foldate,6,2); | 
|---|
| 537 | $starthour =   substr($foldate,8,2); | 
|---|
| 538 | $startmin =   substr($foldate,10,2); | 
|---|
| 539 |  | 
|---|
| 540 | $startepoch = date ("U",mktime($starthour  , $startmin , 0, $startmonth  , $startday, $startyear)); | 
|---|
| 541 | $nowe = time(); | 
|---|
| 542 | if ($startepoch > $nowe){ | 
|---|
| 543 |  | 
|---|
| 544 | return TRUE; | 
|---|
| 545 | }else{ | 
|---|
| 546 | return FALSE; | 
|---|
| 547 | } | 
|---|
| 548 | }else{ | 
|---|
| 549 | return FALSE; | 
|---|
| 550 | } | 
|---|
| 551 |  | 
|---|
| 552 | } | 
|---|
| 553 |  | 
|---|
| 554 |  | 
|---|
| 555 |  | 
|---|
| 556 | function login($con,$name,$passwd){ | 
|---|
| 557 | global $environmentpolicytoken; | 
|---|
| 558 |  | 
|---|
| 559 |  | 
|---|
| 560 | if (((mb_ereg('[^0-9a-zA-Z]', $name)) ||(mb_ereg('[^0-9a-zA-Z]', $passwd) ))){ | 
|---|
| 561 |  | 
|---|
| 562 |  | 
|---|
| 563 |  | 
|---|
| 564 | redirectlogin(); | 
|---|
| 565 |  | 
|---|
| 566 |  | 
|---|
| 567 |  | 
|---|
| 568 |  | 
|---|
| 569 | escape_string($name); | 
|---|
| 570 | escape_string($passwd); | 
|---|
| 571 |  | 
|---|
| 572 | $query = " | 
|---|
| 573 | SELECT memberid ,userclass,name,passwd1 | 
|---|
| 574 | FROM foltia_envpolicy | 
|---|
| 575 | WHERE foltia_envpolicy.name  = '$name' | 
|---|
| 576 | "; | 
|---|
| 577 | $useraccount = m_query($con, $query, "DBクエリに失敗しました"); | 
|---|
| 578 | $rowdata = $useraccount->fetch(); | 
|---|
| 579 | if (! $rowdata) { | 
|---|
| 580 | header("HTTP/1.0 401 Unauthorized"); | 
|---|
| 581 | redirectlogin(); | 
|---|
| 582 | } | 
|---|
| 583 |  | 
|---|
| 584 | $memberid = $rowdata[0]; | 
|---|
| 585 | $userclass = $rowdata[1]; | 
|---|
| 586 | $username =  $rowdata[2]; | 
|---|
| 587 | $dbpasswd = $rowdata[3]; | 
|---|
| 588 |  | 
|---|
| 589 | $rowdata = $useraccount->fetch(); | 
|---|
| 590 | if ($rowdata) { | 
|---|
| 591 | header("HTTP/1.0 401 Unauthorized"); | 
|---|
| 592 | redirectlogin(); | 
|---|
| 593 | } | 
|---|
| 594 |  | 
|---|
| 595 |  | 
|---|
| 596 | if ($userclass == 0){ | 
|---|
| 597 | $dbpasswd = "$dbpasswd"; | 
|---|
| 598 | }else{ | 
|---|
| 599 |  | 
|---|
| 600 | $dbpasswd = "$dbpasswd"."$environmentpolicytoken"; | 
|---|
| 601 | } | 
|---|
| 602 |  | 
|---|
| 603 | if ($passwd == $dbpasswd) { | 
|---|
| 604 |  | 
|---|
| 605 | }else{ | 
|---|
| 606 |  | 
|---|
| 607 | header("HTTP/1.0 401 Unauthorized"); | 
|---|
| 608 |  | 
|---|
| 609 | redirectlogin(); | 
|---|
| 610 |  | 
|---|
| 611 |  | 
|---|
| 612 | } | 
|---|
| 613 |  | 
|---|
| 614 |  | 
|---|
| 615 |  | 
|---|
| 616 |  | 
|---|
| 617 | function redirectlogin(){ | 
|---|
| 618 | global $environmentpolicytoken; | 
|---|
| 619 |  | 
|---|
| 620 | print "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\n"; | 
|---|
| 621 | print "<html><head>\n"; | 
|---|
| 622 | print "<title>foltia:Invalid login</title>\n"; | 
|---|
| 623 | print "</head><body>\n"; | 
|---|
| 624 | print "<h1>Invalid login</h1>"; | 
|---|
| 625 | print "<p>foltiaヘのアクセスにはログインが必要です。再ログインはリロードやブラウザ再起動で、新規アカウント登録は<a href=\"./accountregist.php\">こちらから。</a></p>"; | 
|---|
| 626 | if ($environmentpolicytoken == ""){ | 
|---|
| 627 | }else{ | 
|---|
| 628 | print "<p>突然この画面が表示された場合にはセキュリティコードが変更されたかも知れません。</p>"; | 
|---|
| 629 | } | 
|---|
| 630 | print "</p><hr>\n"; | 
|---|
| 631 | 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"; | 
|---|
| 632 | print "</body></html>\n"; | 
|---|
| 633 |  | 
|---|
| 634 |  | 
|---|
| 635 |  | 
|---|
| 636 | exit; | 
|---|
| 637 | } | 
|---|
| 638 |  | 
|---|
| 639 | function getuserclass($con){ | 
|---|
| 640 | global $useenvironmentpolicy; | 
|---|
| 641 | $username = $_SERVER['PHP_AUTH_USER']; | 
|---|
| 642 |  | 
|---|
| 643 | if ($useenvironmentpolicy == 1){ | 
|---|
| 644 | $query = " | 
|---|
| 645 | SELECT memberid ,userclass,name,passwd1 | 
|---|
| 646 | FROM foltia_envpolicy | 
|---|
| 647 | WHERE foltia_envpolicy.name  = '$username' | 
|---|
| 648 | "; | 
|---|
| 649 | $useraccount = m_query($con, $query, "DBクエリに失敗しました"); | 
|---|
| 650 | $rowdata = $useraccount->fetch(); | 
|---|
| 651 | if (! $rowdata) { | 
|---|
| 652 | return (99); | 
|---|
| 653 | } | 
|---|
| 654 |  | 
|---|
| 655 | $userclass = $rowdata[1]; | 
|---|
| 656 |  | 
|---|
| 657 | $rowdata = $useraccount->fetch(); | 
|---|
| 658 | if ($rowdata) { | 
|---|
| 659 | return (99); | 
|---|
| 660 | } | 
|---|
| 661 |  | 
|---|
| 662 | return ($userclass); | 
|---|
| 663 |  | 
|---|
| 664 | }else{ | 
|---|
| 665 | return (0); | 
|---|
| 666 | } | 
|---|
| 667 | } | 
|---|
| 668 |  | 
|---|
| 669 |  | 
|---|
| 670 |  | 
|---|
| 671 | function getmymemberid($con){ | 
|---|
| 672 | global $useenvironmentpolicy; | 
|---|
| 673 | $username = $_SERVER['PHP_AUTH_USER']; | 
|---|
| 674 |  | 
|---|
| 675 | if ($useenvironmentpolicy == 1){ | 
|---|
| 676 | $query = " | 
|---|
| 677 | SELECT memberid ,userclass,name,passwd1 | 
|---|
| 678 | FROM foltia_envpolicy | 
|---|
| 679 | WHERE foltia_envpolicy.name  = '$username' | 
|---|
| 680 | "; | 
|---|
| 681 | $useraccount = m_query($con, $query, "DBクエリに失敗しました"); | 
|---|
| 682 | $rowdata = $useraccount->fetch(); | 
|---|
| 683 | if (! $rowdata) { | 
|---|
| 684 | return (-1); | 
|---|
| 685 | } | 
|---|
| 686 |  | 
|---|
| 687 | $memberid = $rowdata[0]; | 
|---|
| 688 |  | 
|---|
| 689 | $rowdata = $useraccount->fetch(); | 
|---|
| 690 | if ($rowdata) { | 
|---|
| 691 | return (-1); | 
|---|
| 692 | } | 
|---|
| 693 |  | 
|---|
| 694 | return ($memberid); | 
|---|
| 695 |  | 
|---|
| 696 | }else{ | 
|---|
| 697 | return (0); | 
|---|
| 698 | } | 
|---|
| 699 | } | 
|---|
| 700 |  | 
|---|
| 701 |  | 
|---|
| 702 | function getmemberid2name($con,$memberid){ | 
|---|
| 703 | global $useenvironmentpolicy; | 
|---|
| 704 |  | 
|---|
| 705 |  | 
|---|
| 706 | if ($useenvironmentpolicy == 1){ | 
|---|
| 707 | $query = " | 
|---|
| 708 | SELECT memberid ,userclass,name,passwd1 | 
|---|
| 709 | FROM foltia_envpolicy | 
|---|
| 710 | WHERE foltia_envpolicy.memberid  = '$memberid' | 
|---|
| 711 | "; | 
|---|
| 712 | $useraccount = m_query($con, $query, "DBクエリに失敗しました"); | 
|---|
| 713 | $rowdata = $useraccount->fetch(); | 
|---|
| 714 | if (! $rowdata) { | 
|---|
| 715 | return (""); | 
|---|
| 716 | } | 
|---|
| 717 |  | 
|---|
| 718 | $name = $rowdata[2]; | 
|---|
| 719 |  | 
|---|
| 720 | $rowdata = $useraccount->fetch(); | 
|---|
| 721 | if ($rowdata) { | 
|---|
| 722 | return (""); | 
|---|
| 723 | } | 
|---|
| 724 |  | 
|---|
| 725 | return ($name); | 
|---|
| 726 |  | 
|---|
| 727 | }else{ | 
|---|
| 728 | return (""); | 
|---|
| 729 | } | 
|---|
| 730 |  | 
|---|
| 731 | } | 
|---|
| 732 |  | 
|---|
| 733 | ?> | 
|---|
| 734 |  | 
|---|