root/trunk/install/php/foltialib.php

リビジョン 96, 18.0 kB (コミッタ: sorshi, コミット時期: 16 年 前)

foltialib.phpのsql_query()のデフォルト引数追加
(foltia簡易BBS:foltialib.phpのsql_queryの呼び出し:投稿日 2010年03月06日07時21分45秒 投稿者 ψ(プサイ))

Line 
1 <?php
2 /*
3  Anime recording system foltia
4  http://www.dcc-jpl.com/soft/foltia/
5
6 viewepg.php
7
8 目的
9 番組録画予約ページを表示します。
10
11 オプション
12 start:表示タイムスタンプ(Ex.200512281558)
13  省略時、現在時刻。
14
15  DCC-JPL Japan/foltia project
16
17 */
18
19 include("./foltialib.php");
20 $con = m_connect();
21
22 if ($useenvironmentpolicy == 1){
23     if (!isset($_SERVER['PHP_AUTH_USER'])) {
24         header("WWW-Authenticate: Basic realm=\"foltia\"");
25         header("HTTP/1.0 401 Unauthorized");
26         redirectlogin();
27         exit;
28     } else {
29     login($con,$_SERVER['PHP_AUTH_USER'],$_SERVER['PHP_AUTH_PW']);
30     }
31 }//end if login
32 ?>
33 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
34 <html lang="ja">
35 <head>
36 <meta http-equiv="Content-Type" content="text/html; charset=EUC-JP">
37 <meta http-equiv="Content-Style-Type" content="text/css">
38 <link rel="stylesheet" type="text/css" href="graytable.css">
39 <title>foltia:EPG番組表</title>
40 </head>
41 <?php
42 $start = getgetnumform("start");
43
44 if ($start == ""){
45     $start date("YmdHi");
46 }else{
47   $start = ereg_replace( "[^0-9]", "", $start);
48 }
49 ?>
50 <body BGCOLOR="#ffffff" TEXT="#494949" LINK="#0047ff" VLINK="#000000" ALINK="#c6edff" >
51 <div align="center">
52 <?php
53 printhtmlpageheader();
54 ?>
55 <p align="left"><font color="#494949" size="6">EPG番組表</font></p>
56 <p align="left"><a href="./m.php">番組手動予約</a ></p>
57 <hr size="4">
58 <p align="left">EPG番組表を表示します。
59 <?php
60
61 $startyear =   substr($start,0,4);
62 $startmonth =   substr($start,4,2);
63 $startday =   substr($start,6,2);
64 $starthour =   substr($start,8,2);
65 $startmin =   substr($start,10,2);
66 print "($startyear/$startmonth/$startday $starthour:$startmin-)<BR>\n";
67
68 $yesterday = date ("YmdHi",mktime($starthour , 0 , 0, $startmonth , $startday -1 , $startyear));
69 $today0400 = date ("YmdHi",mktime(4 , 0 , 0, $startmonth , $startday  , $startyear));
70 $today1200 = date ("YmdHi",mktime(12 , 0 , 0, $startmonth , $startday , $startyear));
71 $today2000 = date ("YmdHi",mktime(20 , 0 , 0, $startmonth , $startday , $startyear));
72 $day1after = date ("YmdHi",mktime($starthour , 0 , 0, $startmonth , $startday +1 , $startyear));
73 $day1 = date ("m/d",mktime($starthour , 0 , 0, $startmonth , $startday +1 , $startyear));
74 $day2after = date ("YmdHi",mktime($starthour , 0 , 0, $startmonth , $startday +2 , $startyear));
75 $day2 = date ("m/d",mktime($starthour , 0 , 0, $startmonth , $startday +2 , $startyear));
76 $day3after = date ("YmdHi",mktime($starthour , 0 , 0, $startmonth , $startday +3 , $startyear));
77 $day3 = date ("m/d",mktime($starthour , 0 , 0, $startmonth , $startday +3 , $startyear));
78 $day4after = date ("YmdHi",mktime($starthour , 0 , 0, $startmonth , $startday +4 , $startyear));
79 $day4 = date ("m/d",mktime($starthour , 0 , 0, $startmonth , $startday +4 , $startyear));
80 $day5after = date ("YmdHi",mktime($starthour , 0 , 0, $startmonth , $startday +5 , $startyear));
81 $day5 = date ("m/d",mktime($starthour , 0 , 0, $startmonth , $startday +5 , $startyear));
82 $day6after = date ("YmdHi",mktime($starthour , 0 , 0, $startmonth , $startday +6 , $startyear));
83 $day6 = date ("m/d",mktime($starthour , 0 , 0, $startmonth , $startday +6 , $startyear));
84 $day7after = date ("YmdHi",mktime($starthour , 0 , 0, $startmonth , $startday +7 , $startyear));
85 $day7 = date ("m/d",mktime($starthour , 0 , 0, $startmonth , $startday +7 , $startyear));
86
87
88
89 //表示局選定
90 // $page = 1 ~
91 $maxdisplay = 8;
92
93 $query = "SELECT count(*) FROM foltia_station WHERE \"ontvcode\" LIKE '%ontvjapan%'";
94 //$rs = m_query($con, $query, "DBクエリに失敗しました");
95 $rs = sql_query($con, $query, "DBクエリに失敗しました");
96 $maxrows = $rs->fetchColumn(0);
97 if ($maxrows > $maxdisplay){
98     $pages = ceil($maxrows / $maxdisplay) ;
99 }
100
101 $page = getgetnumform("p");
102
103 if (($page == "")|| ($page <= 0) ){
104     $page = 1 ;
105     $offset = ;
106 }else{
107   $page = ereg_replace( "[^0-9]", "", $page);
108   if ($page > $pages){
109       $page = $pages ;
110   }elseif ($page <= 0) {
111   $page = 1 ;
112   }
113   $offset = ($page * $maxdisplay ) - $maxdisplay;
114 }
115
116
117 print "←<A HREF=\"./viewepg.php?p=$page&start=$yesterday\">前の日</A> <A HREF=\"./viewepg.php\">現在</A> 当日(<A HREF=\"./viewepg.php?p=$page&start=$today0400\">4:00</A> <A HREF=\"./viewepg.php?p=$page&start=$today1200\">12:00</A> <A HREF=\"./viewepg.php?p=$page&start=$today2000\">20:00</A>) <A HREF=\"./viewepg.php?p=$page&start=$day1after\">次の日</A> <A HREF=\"./viewepg.php?p=$page&start=$day2after\">$day2</A> <A HREF=\"./viewepg.php?p=$page&start=$day3after\">$day3</A> <A HREF=\"./viewepg.php?p=$page&start=$day4after\">$day4</A> <A HREF=\"./viewepg.php?p=$page&start=$day5after\">$day5</A> <A HREF=\"./viewepg.php?p=$page&start=$day6after\">$day6</A> <A HREF=\"./viewepg.php?p=$page&start=$day7after\">$day7</A>→<BR>\n";
118
119
120 if ($maxrows > $maxdisplay){
121 //複数ページ
122 //$pages = ceil($maxrows / $maxdisplay) ;
123 if ($page > 1){
124     $beforepage = $page - 1;
125     print "<a href = \"./viewepg.php?p=$beforepage&start=$start\">←</A>";
126 }
127
128 print " $page / $pages (放送局) ";
129
130 if ($page < $pages){
131     $nextpage = $page + 1;
132     print "<a href = \"./viewepg.php?p=$nextpage&start=$start\">→</A>";
133 }
134 }
135 //ココから新コード
136 //・局リスト
137 $query = "SELECT stationid, stationname, stationrecch, ontvcode
138 FROM foltia_station
139 WHERE \"ontvcode\" LIKE '%ontvjapan%' 
140 ORDER BY stationid ASC , stationrecch
141 LIMIT ? OFFSET ?
142 ";
143
144 //$slistrs = m_query($con, $query, "DBクエリに失敗しました");
145 $slistrs = sql_query($con, $query, "DBクエリに失敗しました",array($maxdisplay,$offset));
146 while ($rowdata = $slistrs->fetch()) {
147     $stationhash[] = $rowdata[3];
148     $snames[] = $rowdata[1]; // headder
149 }
150
151 //・時間と全順番のハッシュ作る
152 $epgstart = $start ;
153 $epgend = calcendtime($start , (8*60));
154
155 $query = "SELECT DISTINCT startdatetime   
156 FROM foltia_epg
157 WHERE foltia_epg.ontvchannel in (
158     SELECT ontvcode
159     FROM foltia_station
160     WHERE \"ontvcode\" LIKE '%ontvjapan%' 
161     ORDER BY stationid ASC , stationrecch
162     LIMIT ? OFFSET ?
163     )
164 AND startdatetime  >= ?
165 AND startdatetime  < ?
166 ORDER BY foltia_epg.startdatetime  ASC    ";
167
168 //$rs = m_query($con, $query, "DBクエリに失敗しました");
169 $rs = sql_query($con, $query, "DBクエリに失敗しました",array($maxdisplay,$offset,$start,$epgend));
170
171 //print "$query<br>\n";
172
173 $rowdata = $rs->fetch();
174 if (! $rowdata) {
175 //番組データがない
176 $colmnums = 2;
177 }else{
178     $colmnums = 0;
179     do {
180         $colmnums++;
181         $timetablehash[$rowdata[0]] = $colmnums;
182 //        print "$rowdata[0]:$i+1 <br>\n";
183     } while ($rowdata = $rs->fetch());
184 }
185 //print "colmnums $colmnums <br>\n";
186
187 //・局ごとに縦に配列入れていく
188 foreach ($stationhash as $stationname) {
189 $epgstart = $start ;
190 $epgend = calcendtime($start , (8*60));
191 $query = "
192 SELECT startdatetime , enddatetime , lengthmin , epgtitle , epgdesc , epgcategory  ,ontvchannel  ,epgid ,    epgcategory
193 FROM foltia_epg
194 WHERE foltia_epg.ontvchannel = ? AND
195 enddatetime  > ?  AND
196 startdatetime  < ? 
197 ORDER BY foltia_epg.startdatetime  ASC
198     ";
199
200 //    $statiodh = m_query($con, $query, "DBクエリに失敗しました");
201     $statiodh = sql_query($con, $query, "DBクエリに失敗しました",array($stationname,$epgstart,$epgend));
202     $stationrowdata = $statiodh->fetch();
203     if (! $stationrowdata) {
204         //print("番組データがありません<BR>");
205         $item[0]["$stationname"] =  ">番組データがありません";
206 }else{
207         do {
208 $printstarttime = substr($stationrowdata[0],8,2) . ":" substr($stationrowdata[0],10,2);
209 $tdclass = "t".substr($stationrowdata[0],8,2) .  substr($stationrowdata[0],10,2);
210 $title = $stationrowdata[3];
211 $title = htmlspecialchars(z2h($title));
212 $desc = $stationrowdata[4];
213 $desc = htmlspecialchars(z2h($desc));
214 $height htmlspecialchars($stationrowdata[2]) * 3;
215 $epgid htmlspecialchars($stationrowdata[7]);
216 $epgcategory = htmlspecialchars($stationrowdata[8]);
217
218 if (isset($timetablehash["$stationrowdata[0]"])){
219     $number = $timetablehash["$stationrowdata[0]"];
220 //print "$stationname $stationrowdata[0] [$number] $printstarttime $title $desc<br>\n";
221 }else{
222     $number = 0;
223 //print "$stationname $stationrowdata[0] 現在番組 $printstarttime $title $desc<br>\n";
224 }
225 if ($epgcategory == ""){
226 $item["$number"]["$stationname"] =  " onClick=\"location = './reserveepg.php?epgid=$epgid'\"><span id=\"epgstarttime\">$printstarttime</span> <A HREF=\"./reserveepg.php?epgid=$epgid\"><span id=\"epgtitle\">$title</span></A> <span id=\"epgdesc\">$desc</span>";
227 }else{
228 $item["$number"]["$stationname"] =  " id=\"$epgcategory\" onClick=\"location = './reserveepg.php?epgid=$epgid'\"><span id=\"epgstarttime\">$printstarttime</span> <A HREF=\"./reserveepg.php?epgid=$epgid\"><span id=\"epgtitle\">$title</span></A> <span id=\"epgdesc\">$desc</span></span>";
229 }//if
230
231         } while ($stationrowdata = $statiodh->fetch());
232 }//if
233
234 //・局ごとに間隔決定
235 //$item[$i][NHK] はヌルかどうか判定
236 $dataplace = 0 ; //初期化
237 $rowspan = 0;
238
239 for ($i=1; $i <= $colmnums ; $i++){
240     if ($i === ($colmnums )){//最終行
241         $rowspan = $i - $dataplace ;
242         //そして自分自身にタグを
243             //if ((!isset($item[$i][$stationname])) && ($item[$i][$stationname] == "")){
244             if (!isset($item[$i][$stationname])){
245             $item[$i][$stationname]  = null ;
246             }else{
247             $item[$i][$stationname]  = "<td ". $item[$i][$stationname] . "</td>";
248             $rowspan--;
249             }
250             //ROWSPAN
251             if ($rowspan === 1 ){
252             $item[$dataplace][$stationname]  = "<td ". $item[$dataplace][$stationname] . "</td>";
253             }else{
254             $item[$dataplace][$stationname]  = "<td  rowspan = $rowspan ". $item[$dataplace][$stationname] . "</td>";
255 //            $item[$dataplace][$stationname]  = "<td ". $item[$dataplace][$stationname] . "$rowspan </td>";
256             }
257
258 //    }elseif ((!isset($item[$i][$stationname]))&&($item[$i][$stationname] == "")){
259     }elseif (!isset($item[$i][$stationname])){
260     //ヌルなら
261         //$item[$i][$stationname]  =  $item[$i][$stationname] ;
262         $item[$i][$stationname]  =  null ;
263 //        $item[$i][$stationname]  =  "<td><br></td>" ;
264     }else{
265     //なんか入ってるなら
266         $rowspan = $i - $dataplace;
267         $itemDataplaceStationname = null;
268         if (isset($item[$dataplace][$stationname])){
269         $itemDataplaceStationname = $item[$dataplace][$stationname];
270         }
271             if ($rowspan === 1 ){
272             $item[$dataplace][$stationname]  = "<td ". $itemDataplaceStationname . "</td>";
273             }else{
274             $item[$dataplace][$stationname]  = "<td rowspan = $rowspan ". $itemDataplaceStationname . "</td>";
275 //            $item[$dataplace][$stationname]  = "<td ". $item[$dataplace][$stationname] . "$rowspan </td>";
276             }
277         $dataplace = $i;
278         
279     }
280 }//for
281 }// end of for://・局ごとに縦に配列入れていく
282
283 //・テーブルレンダリング
284 print "<table>\n<tr>";
285
286 //ヘッダ
287 foreach ($snames as $s) {
288     print "<th>".htmlspecialchars($s)."</th>" ;
289 }
290 //本体
291 for ($l = 0 ;$l $colmnums; $l++){
292     print "<tr>";
293     foreach ($stationhash as $stationname) {
294         print_r($item[$l]["$stationname"]);
295     }
296     print "</tr>\n";
297 }
298 print "</table>\n";
299  ?>
300
301 <hr>
302 凡例
303 <table>
304 <tr>
305 <td id="information">情報</td>
306 <td id="anime">アニメ・特撮</td>
307 <td id="news">ニュース・報道</td>
308 <td id="drama">ドラマ</td>
309 <td id="variety">バラエティ</td>
310 <td id="documentary">ドキュメンタリー・教養</td>
311 <td id="education">教育</td>
312 <td id="music">音楽</td>
313 <td id="cinema">映画</td>
314 <td id="hobby">趣味・実用</td>
315 <td id="kids">キッズ</td>
316 <td id="sports">スポーツ</td>
317 <td id="etc">その他</td>
318 <td id="stage">演劇</td>
319
320 </tr>
321 </table>
322 </body>
323 </html>
324
325
326 = $_SERVER['SCRIPT_NAME'];///dameNews/sarasorjyu/archives.php
327 $sv8 = $_SERVER['SERVER_NAME'];//sync.dcc-jpl.com
328 $sv9 = $_SERVER['SERVER_PORT'];
329 if ($sv9 == 80){
330     $port = "";
331 }else{
332     $port = ":$sv9";
333 }
334 $a = split("/", $sv6);
335 array_pop($a);
336
337 $scriptpath = implode("/", $a);
338
339 $serveruri = "$sv8$port$scriptpath";
340 return ($serveruri );
341 }//end sub
342
343
344 function getserverfqdn(){//戻り値 サーバアドレス Ex.www.dcc-jpl.com:8800
345
346 //リンクURI組み立て
347 $sv6 = $_SERVER['SCRIPT_NAME'];///dameNews/sarasorjyu/archives.php
348 $sv8 = $_SERVER['SERVER_NAME'];//sync.dcc-jpl.com
349 $sv9 = $_SERVER['SERVER_PORT'];
350 if ($sv9 == 80){
351     $port = "";
352 }else{
353     $port = ":$sv9";
354 }
355 $a = split("/", $sv6);
356 array_pop($a);
357
358 $scriptpath = implode("/", $a);
359
360 $serveruri = "$sv8$port";
361 return ($serveruri );
362 }//end sub
363
364
365 function printdiskusage(){//戻り値 なし
366 list (, $all, $use , $free, $usepercent) =  getdiskusage();
367
368 print "
369 <div style=\"width:100%;border:1px solid black;text-align:left;\"><span style=\"float:right;\">$free</span>
370 <div style=\"width:$usepercent;border:1px solid black;background:white;\">$use/$all($usepercent)</div>
371 </div>
372 ";
373 //exec('ps ax | grep ffmpeg |grep MP4 ' ,$ffmpegprocesses);
374 }//end sub
375
376
377 function getdiskusage(){//戻り値 配列 [,全体容量, 使用容量 , 空き容量, 利用割合]
378
379 global $recfolderpath,$recfolderpath;
380
381 //    exec ( "df -h  $recfolderpath | grep $recfolderpath", $hdfreearea);
382 //    $freearea = preg_split ("/[\s,]+/", $hdfreearea[0]);
383     exec ( "df -hP  $recfolderpath", $hdfreearea);
384     $freearea = preg_split ("/[\s,]+/", $hdfreearea[count($hdfreearea)-1]);
385
386     return $freearea;
387    
388 }//endsub
389
390
391 function printtrcnprocesses(){
392
393 $ffmpegprocesses = `ps ax | grep ffmpeg | grep -v grep |  wc -l `;
394 $uptime = exec('uptime');
395
396 print "<div style=\"text-align:left;\">";
397 print "$uptime<br>\n";
398 print "トラコン稼働数:$ffmpegprocesses<br>\n";
399 print "</div>";
400
401 }//endsub
402
403
404 function warndiskfreearea(){
405
406 global $demomode;
407
408 if ($demomode){
409 print "<!-- demo mode -->";
410 }else{
411
412 global $recfolderpath,$hdfreearea ;
413
414     exec ( "df   $recfolderpath | grep $recfolderpath", $hdfreearea);
415     $freearea = preg_split ("/[\s,]+/", $hdfreearea[0]);
416 $freebytes = $freearea[3];
417 if ($freebytes == "" ){
418 //
419 //print "<!-- err:\$freebytes is null -->";
420 }elseif($freebytes > 1024*1024*100 ){// 100GB以上あいてれば
421 //なにもしない
422 print "<style type=\"text/css\"><!-- --></style>";
423 }elseif($freebytes > 1024*1024*50 ){// 100GB以下
424 print "<style type=\"text/css\"><!--
425     body {
426     background-color: #CCCC99;
427      }
428 -->
429 </style>
430 ";
431 }elseif($freebytes > 1024*1024*30 ){// 50GB以下
432 print "<style type=\"text/css\"><!--
433     body {
434     background-color:#CC6666;
435      }
436 -->
437 </style>
438 ";
439 }elseif($freebytes > 0 ){// 30GB以下
440 print "<style type=\"text/css\"><!--
441     body {
442     background-color:#FF0000;
443      }
444 -->
445 </style>
446 ";
447 }else{ //空き容量 0バイト
448 print "<style type=\"text/css\"><!--
449     body {
450     background-color:#000000;
451      }
452 -->
453 </style>
454 ";
455 }//endif freebytess
456
457 }//endif demomode
458
459 }//endsub
460
461
462
463 function foldatevalidation($foldate){
464
465 if (strlen($foldate) == 12 ){
466
467     $startyear =   substr($foldate,0,4);
468     $startmonth =   substr($foldate,4,2);
469     $startday =   substr($foldate,6,2);
470     $starthour =   substr($foldate,8,2);
471     $startmin =   substr($foldate,10,2);
472
473     $startepoch = date ("U",mktime($starthour  , $startmin , 0, $startmonth  , $startday, $startyear));   
474     $nowe = time();
475     if ($startepoch > $nowe){
476     //print "$foldate:$startepoch:$nowe";
477         return TRUE;
478     }else{
479         return FALSE;
480     }    //end if $startepoch > $nowe
481 }else{
482     return FALSE;
483 }//end if ($foldate) == 12
484
485 }//end function
486
487
488
489 function login($con,$name,$passwd){
490 global $environmentpolicytoken;
491
492 //入力内容確認
493  if (((mb_ereg('[^0-9a-zA-Z]', $name)) ||(mb_ereg('[^0-9a-zA-Z]', $passwd) ))){
494    
495     //print "エラー処理\n";
496     //print "<!-- DEBUG name/passwd format error-->";
497     redirectlogin();
498    
499 }else{
500 //print "正常処理\n";
501 //db検索
502 escape_string($name);
503 escape_string($passwd);
504
505 $query = "
506 SELECT memberid ,userclass,name,passwd1
507 FROM foltia_envpolicy
508 WHERE foltia_envpolicy.name  = '$name' 
509     ";
510     $useraccount = m_query($con, $query, "DBクエリに失敗しました");
511         $rowdata = $useraccount->fetch();
512         if (! $rowdata) {
513             header("HTTP/1.0 401 Unauthorized");
514             redirectlogin();
515         }
516    
517         $memberid = $rowdata[0];
518         $userclass = $rowdata[1];
519         $username =  $rowdata[2];
520         $dbpasswd = $rowdata[3];
521
522         $rowdata = $useraccount->fetch();
523         if ($rowdata) {
524         header("HTTP/1.0 401 Unauthorized");
525         redirectlogin();
526         }
527
528 // passwdをdbから取りだし
529 if ($userclass == 0){
530 $dbpasswd = "$dbpasswd";
531 }else{
532 // db passwdとトークンを連結し
533 $dbpasswd = "$dbpasswd"."$environmentpolicytoken";
534 }
535 //それが入力と一致すれば認証
536 if ($passwd == $dbpasswd) {
537 //print "認証成功<br>$dbpasswd  $passwd\n";
538 }else{
539 //print "認証失敗<br>$dbpasswd  $passwd\n";
540         header("HTTP/1.0 401 Unauthorized");
541         //print "<!-- DEBUG passwd unmatch error>";
542         redirectlogin();
543 }
544 }//end if mb_ereg
545 }//end function login
546
547
548
549
550 function redirectlogin(){
551 global $environmentpolicytoken;
552
553 print "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\n";
554 print "<html><head>\n";
555 print "<title>foltia:Invalid login</title>\n";
556 print "</head><body>\n";
557 print "<h1>Invalid login</h1>";
558 print "<p>foltiaヘのアクセスにはログインが必要です。再ログインはリロードやブラウザ再起動で、新規アカウント登録は<a href=\"./accountregist.php\">こちらから。</a></p>";
559 if ($environmentpolicytoken == ""){
560 }else{
561     print "<p>突然この画面が表示された場合にはセキュリティコードが変更されたかも知れません。</p>";
562 }
563 print "</p><hr>\n";
564 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";
565 print "</body></html>\n";
566
567
568
569 exit;
570 }//end function redirectlogin
571
572 function getuserclass($con){
573 global $useenvironmentpolicy;
574 $username = $_SERVER['PHP_AUTH_USER'];
575
576 if ($useenvironmentpolicy == 1){
577 $query = "
578 SELECT memberid ,userclass,name,passwd1
579 FROM foltia_envpolicy
580 WHERE foltia_envpolicy.name  = '$username' 
581     ";
582         $useraccount = m_query($con, $query, "DBクエリに失敗しました");
583         $rowdata = $useraccount->fetch();
584         if (! $rowdata) {
585             return (99);
586         }
587    
588         $userclass = $rowdata[1];
589
590         $rowdata = $useraccount->fetch();
591         if ($rowdata) {
592             return (99);
593         }
594
595         return ($userclass);
596    
597 }else{
598     return (0);//環境ポリシー使わないときはつねに特権モード
599 }//end if
600 }//end function getuserclass
601
602
603
604 function getmymemberid($con){
605 global $useenvironmentpolicy;
606 $username = $_SERVER['PHP_AUTH_USER'];
607
608 if ($useenvironmentpolicy == 1){
609 $query = "
610 SELECT memberid ,userclass,name,passwd1
611 FROM foltia_envpolicy
612 WHERE foltia_envpolicy.name  = '$username' 
613     ";
614         $useraccount = m_query($con, $query, "DBクエリに失敗しました");
615         $rowdata = $useraccount->fetch();
616         if (! $rowdata) {
617     return (-1);//エラー
618         }
619
620         $memberid = $rowdata[0];
621
622         $rowdata = $useraccount->fetch();
623         if ($rowdata) {
624             return (-1);
625         }
626
627         return ($memberid);
628    
629 }else{
630     return (0);//環境ポリシー使わないときはつねに特権モード
631 }//end if
632 }//end function getuserclass
633
634
635 function getmemberid2name($con,$memberid){
636 global $useenvironmentpolicy;
637 //$username = $_SERVER['PHP_AUTH_USER'];
638
639 if ($useenvironmentpolicy == 1){
640 $query = "
641 SELECT memberid ,userclass,name,passwd1
642 FROM foltia_envpolicy
643 WHERE foltia_envpolicy.memberid  = '$memberid' 
644     ";
645         $useraccount = m_query($con, $query, "DBクエリに失敗しました");
646         $rowdata = $useraccount->fetch();
647         if (! $rowdata) {
648     return ("");//エラー
649         }
650    
651         $name = $rowdata[2];
652
653         $rowdata = $useraccount->fetch();
654         if ($rowdata) {
655     return ("");
656         }
657
658         return ($name);
659
660     }else{
661         return ("");
662     }//end if
663
664 }//end function getmemberid2name
665
666 ?>
667
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。
track feed