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