• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Aucun tag

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

OpengateM Source Repository


Commit MetaInfo

Révision830e46491dd03d88e9544346ae21f1811cf4fd71 (tree)
l'heure2014-02-28 15:11:17
Auteurwatanaby <watanaby@user...>
Commiterwatanaby

Message de Log

changed log table to chart. Added status P(=Pause).

Change Summary

Modification

--- a/doc/Changes.html
+++ b/doc/Changes.html
@@ -225,6 +225,11 @@ OpengateM History</H3>
225225 </DT><DD>
226226 Modified mac cache to store not-found info (opengatemd).
227227 </DD>
228+ <DT>Ver.0.9.0 at 2014.2.28
229+ </DT><DD>
230+ Changed log table in the update page to chart format (opengatemup).
231+ Added status='P' to represent "Pause" (opengatemup).
232+ </DD>
228233 </DL>
229234
230235 </BODY>
--- a/html/en/macupdate.html
+++ b/html/en/macupdate.html
@@ -2,6 +2,14 @@
22 <head>
33 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
44 <title></title>
5+<script type="text/javascript">
6+<!--
7+var loglist={
8+%%USAGELOG%%
9+};
10+-->
11+</script>
12+<script type="text/javascript" src="/opengate/showlog.js"></script>
513 </head>
614 <body align="center">
715
@@ -32,17 +40,20 @@
3240 %%ERRORLIST%%
3341 </font></p>
3442 <p>
43+<p><strong>To prevent hijacking, please confirm your usage
44+log.</strong>
45+The red border cells in the usage log include two or more records for one device. Please check carefully.
46+</p>
3547
36-<p>Check <strong>"Renew"</strong> to renew the registration (resume
48+<p>Select <strong>Renew</strong> to renew the registration (resume
3749 and extend the limit date).
38-To prevent hijacking, please confirm your usage log at update.
3950 </p>
4051 <p>
41-<strong>"Pause"</strong> sets the limit-date to now to pause the
52+Select <strong>Pause</strong> to pause the
4253 usage. If you want to reuse the device, check "Renew".
4354 </p>
4455 <p>
45-Check <strong>"Delete"</strong> to delete the registration. If you
56+Select <strong>Delete</strong> to delete the registration. If you
4657 may use this terminal in the future, please use "Pause".
4758 </p>
4859 <p>
@@ -51,18 +62,10 @@ reason. Please contact to the administrator.
5162 </p>
5263
5364 <p><font size="5"> usage log </font></p>
54-<p>
55-<table border="1">
56-<tr align="middle">
57-<td> MAC Address </td>
58-<td> Device Name </td>
59-<td> Start Time </td>
60-<td> Week </td>
61-<td> Gateway </td>
6265
63-</tr>
64-%%USAGELOG%%
65-</table>
66-</p>
66+<div id="usagelog"></div>
67+<div id="popup"></div>
68+
69+<p><br><br></p>
6770 </body>
6871 </html>
--- a/html/ja/macupdate.html
+++ b/html/ja/macupdate.html
@@ -2,6 +2,14 @@
22 <head>
33 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
44 <title></title>
5+<script type="text/javascript">
6+<!--
7+var loglist={
8+%%USAGELOG%%
9+};
10+-->
11+</script>
12+<script type="text/javascript" src="/opengate/showlog.js"></script>
513 </head>
614 <body align="center">
715 <p><font size="5">MACアドレス登録更新</font></p>
@@ -33,29 +41,23 @@
3341 %%ERRORLIST%%
3442 </font></p>
3543
36-<p><strong>「更新」</strong>をチェックすると、機器の登録を更新して利用
37-期限を延長します。不正利用を防ぐため、更新時には、下の利用履歴が妥当か確認して下さい。</p>
44+<p><strong>不正利用を防ぐため、下の利用履歴が妥当か確認して下さい。
45+</strong>利用履歴における赤枠セルは1つの機器に対する2つ以上の利用記録を含んでいます。特に注意して下さい。</p>
46+
47+<p><strong>「更新」</strong>をチェックすると、機器の登録を更新して利用期限を延長します。</p>
3848
39-<p><strong>「休止」</strong>をチェックすると、利用期限を早めて利用不可にします。再び利用するときには更新処理をしてください。
49+<p><strong>「休止」</strong>をチェックすると、利用不可にします。再び利用するときには更新処理をしてください。
4050 </p>
4151 <p><strong>「削除」</strong>をチェックすると、機器の登録を削除します。
42-再び利用する可能性が有るときは、休止を利用下さい。
52+再び利用する可能性があるときは、休止を利用下さい。
4353 </p>
44-<p>状態が'I'となっている機器は無効とされています。理由は管理者に問い合わせ下さい。</p>
54+<p>状態が"I"となっている機器は無効とされています。理由は管理者に問い合わせ下さい。</p>
4555
4656
4757 <p><font size="5">利用履歴</font></p>
48-<p>
49-<table border="1">
50- <tr align="middle">
51- <td> MACアドレス</td>
52- <td> 機器名</td>
53- <td> 開始時間</td>
54- <td> 曜日</td>
55- <td> ゲートウェイ</td>
56- </tr>
57-%%USAGELOG%%
58-</table>
59-</p>
58+
59+<div id="usagelog"></div>
60+<div id="popup"></div>
61+<p><br><br></p>
6062 </body>
6163 </html>
--- a/mngsrc/cgi.c
+++ b/mngsrc/cgi.c
@@ -1063,6 +1063,7 @@ int putUpdatePageToClient(char *language, char* userId, char* extraId, int ownUp
10631063 }
10641064
10651065 while(fgets(buff,BUFFMAXLN,fp)!=NULL){
1066+
10661067 HtmlReplace(buff, "%%CGINAME%%", updateCgi);
10671068 HtmlReplace(buff, "%%USERID%%", userId);
10681069 HtmlReplace(buff, "%%REDIRECTEDURL%%", redirectedUrl);
@@ -1101,7 +1102,7 @@ void putMacListToClient(char* userId, char* extraId){
11011102 while(GetNextMacAddrFromMngDb(userId,extraId,macAddr,deviceName,
11021103 entryDate,limitDate,status,mailAddress)){
11031104 printf("<tr align=middle>\n");
1104- if(status[0]=='A'){
1105+ if((status[0]=='A')||(status[0]=='P')){
11051106 printf("<td><input type=radio name=%s value=extend checked></td>\n",macAddr);
11061107 printf("<td><input type=radio name=%s value=pause></td>\n",macAddr);
11071108 printf("<td><input type=radio name=%s value=delete></td>\n",macAddr);
@@ -1124,30 +1125,45 @@ void putMacListToClient(char* userId, char* extraId){
11241125 /*********************************************/
11251126 void putUsageLogToClient(char *userId, char* extraId, char* language){
11261127
1127- char macAddr[ADDRMAXLN];
1128- char deviceName[WORDMAXLN];
1129- char openTime[WORDMAXLN];
1130- char gatewayName[WORDMAXLN];
1131- int weekday;
1132- char str[WORDMAXLN];
1128+ char macAddr[ADDRMAXLN]="";
1129+ char deviceName[WORDMAXLN]="";
1130+ char openTime[WORDMAXLN]="";
1131+ char closeTime[WORDMAXLN]="";
1132+ char gatewayName[WORDMAXLN]="";
1133+ char beginTime[WORDMAXLN]="";
1134+ char endTime[WORDMAXLN]="";
1135+ int dateCount=0;
11331136 char* p;
1137+ int count=0;
11341138
1135- /* get usage log form db and insert as html table row */
1139+ /* get usage log from db and insert as JSON format */
11361140 while(GetNextUsageLogFromMngDb(userId,extraId,macAddr,deviceName,
1137- openTime,gatewayName,&weekday)){
1141+ openTime,closeTime,gatewayName)){
11381142
11391143 /* split hostname only */
11401144 if((p=strchr(gatewayName,'.'))!=NULL) *p='\0';
11411145
11421146 /* put out table row */
1143- printf("<tr align=middle>\n");
1144- printf("<td>%s</td>\n", macAddr);
1145- printf("<td>%s</td>\n",deviceName);
1146- printf("<td>%s</td>\n",openTime);
1147- printf("<td>%s</td>\n",WeekdayStr(weekday, str, language));
1148- printf("<td>%s</td>\n",gatewayName);
1149- printf("</tr>\n");
1147+ printf("\t %d:{\n", count);
1148+ printf("\t\t macAddress: '%s',\n", macAddr);
1149+ printf("\t\t device: '%s',\n",deviceName);
1150+ printf("\t\t openTime: '%s',\n",openTime);
1151+ printf("\t\t closeTime: '%s',\n",closeTime);
1152+ printf("\t\t gateway: '%s'\n",gatewayName);
1153+ printf("\t },\n");
1154+
1155+ /* increment log item counter */
1156+ count++;
11501157 }
1158+
1159+ /* put out informations for the list */
1160+ GetTimeRangeToShowLog(beginTime, endTime, &dateCount);
1161+ printf("\t info:{\n");
1162+ printf("\t\t beginTime: '%s',\n", beginTime);
1163+ printf("\t\t endTime: '%s',\n", endTime);
1164+ printf("\t\t listCount: %d,\n", count);
1165+ printf("\t\t dateCount: %d\n", dateCount);
1166+ printf("\t }\n");
11511167 }
11521168
11531169 /**********************************************/
--- a/mngsrc/managementdb.c
+++ b/mngsrc/managementdb.c
@@ -28,7 +28,6 @@ Email: watanaby@is.saga-u.ac.jp
2828 #include "opengatemmng.h"
2929 #include <mysql.h>
3030
31-
3231 MYSQL mysql;
3332
3433 /******************************************
@@ -381,7 +380,7 @@ int delMacAddrFromMngDb(char* macAddr){
381380 /* don't touch device set as status=Inactive */
382381 snprintf(queryStr, BUFFMAXLN,
383382 "update macaddrs set status='D',limitDate=now() "
384- " where macAddress='%s' and status='A'", macAddr);
383+ " where macAddress='%s' and (status='A' or status='P')", macAddr);
385384 }else{
386385
387386 /* prepare query string */
@@ -389,7 +388,7 @@ int delMacAddrFromMngDb(char* macAddr){
389388 /* don't touch device set as status=Inactive */
390389 snprintf(queryStr, BUFFMAXLN,
391390 "delete from macaddrs "
392- " where macAddress='%s' and status='A'", macAddr);
391+ " where macAddress='%s' and (status='A' or status='P')", macAddr);
393392 }
394393
395394 /* send SQL query */
@@ -412,8 +411,8 @@ int renewMacAddrInMngDb(char* macAddr){
412411 /* prepare query string */
413412 /* don't touch device set as inactive by admin */
414413 snprintf(queryStr, BUFFMAXLN,
415- "update macaddrs set renewDate=now(), limitDate=%s "
416- " where status='A' and macAddress='%s'",
414+ "update macaddrs set status='A', renewDate=now(), limitDate=%s "
415+ " where (status='A' or status='P') and macAddress='%s'",
417416 GetConfValue("LimitDate"),macAddr);
418417
419418 /* send SQL query */
@@ -428,7 +427,6 @@ int renewMacAddrInMngDb(char* macAddr){
428427 /******************************************
429428 pause the usage of the device for a mac address
430429 registered in the management db
431- (set the limitDate to now)
432430 ******************************************/
433431 int pauseMacAddrInMngDb(char* macAddr){
434432
@@ -437,7 +435,7 @@ int pauseMacAddrInMngDb(char* macAddr){
437435 /* prepare query string */
438436 /* don't touch device set as inactive by admin */
439437 snprintf(queryStr, BUFFMAXLN,
440- "update macaddrs set limitDate=now() "
438+ "update macaddrs set status='P' "
441439 " where status='A' and macAddress='%s' and limitDate>now()",
442440 macAddr);
443441
@@ -496,7 +494,7 @@ int isSessionFoundInMngDb(char* macAddr){
496494 get next next usage log from management db
497495 if end of list, return false
498496 *******************************************/
499-int getNextUsageLogFromMngDb(char* userId, char* extraId, char* macAddr, char* deviceName, char* openTime, char* gatewayName, int* weekday){
497+int getNextUsageLogFromMngDb(char* userId, char* extraId, char* macAddr, char* deviceName, char* openTime, char* closeTime, char* gatewayName){
500498 static MYSQL_RES *res=NULL;
501499 MYSQL_ROW row;
502500 char queryStr[BUFFMAXLN];
@@ -509,15 +507,15 @@ int getNextUsageLogFromMngDb(char* userId, char* extraId, char* macAddr, char* d
509507
510508 /* prepare query string */
511509 /* get log where addr.entry < session.open < addr.limit */
510+ /* (the same device may be registered by other users in old days) */
512511 snprintf(queryStr, BUFFMAXLN,
513- "select macaddrs.macAddress as mac, device, openTime, "
514- " gatewayName, weekday(openTime), date(openTime) as dt "
512+ "select macaddrs.macAddress, device, openTime, closeTime, "
513+ " gatewayName "
515514 " from macaddrs, sessionmd "
516515 " where macaddrs.macAddress=sessionmd.macAddress "
517516 " and entryDate < openTime and openTime < limitDate "
518- " and %s < openTime "
519- " and userId='%s' and extraId='%s'"
520- " group by dt,mac order by openTime desc",
517+ " and (%s<closeTime or closeTime=0) "
518+ " and userId='%s' and extraId='%s'",
521519 GetConfValue("ShowLogAfter"), userId, extraId);
522520
523521 /* send SQL query */
@@ -539,8 +537,8 @@ int getNextUsageLogFromMngDb(char* userId, char* extraId, char* macAddr, char* d
539537 strncpy(macAddr, row[0],ADDRMAXLN);
540538 strncpy(deviceName,row[1],WORDMAXLN);
541539 strncpy(openTime,row[2],WORDMAXLN);
542- strncpy(gatewayName,row[3],WORDMAXLN);
543- *weekday=atoi(row[4]);
540+ strncpy(closeTime,row[3],WORDMAXLN);
541+ strncpy(gatewayName,row[4],WORDMAXLN);
544542 return TRUE;
545543 }
546544 /* if not found, free memory area */
@@ -550,6 +548,7 @@ int getNextUsageLogFromMngDb(char* userId, char* extraId, char* macAddr, char* d
550548 }
551549 }
552550
551+
553552 /*******************************************
554553 get next mail address near limit date
555554 from management db
@@ -575,10 +574,11 @@ int getNextMailAddressFromMngDb(char* mailAddress, char* limitDate, char* device
575574 /* [select mailAddress,limitDate,device from macaddrs
576575 where ( date(now())=date(adddate(limitDate, interval -1 day))
577576 OR date(now())=date(adddate(limitDate, interval -7 day)) )
578- AND status='A'] */
577+ AND (status='A' OR status='P')] */
579578 snprintf(queryStr, BUFFMAXLN,
580579 "select mailAddress,limitDate,device from macaddrs "
581- " where (%s) and status='A'", mailTiming);
580+ " where (%s) and (status='A' or status='P')", mailTiming);
581+ /* mailTiming is a condition string defined in conf file */
582582
583583 /* send SQL query */
584584 if (mysql_query(&mysql, queryStr)){
@@ -608,6 +608,66 @@ int getNextMailAddressFromMngDb(char* mailAddress, char* limitDate, char* device
608608 }
609609 }
610610
611+/*******************************************
612+ get the date corresponding to ShowLogAfter in conf file
613+*******************************************/
614+int getTimeRangeToShowLog(char* beginTime, char* endTime, int* dateCount){
615+
616+ static MYSQL_RES *res=NULL;
617+ MYSQL_ROW row;
618+ char queryStr[BUFFMAXLN];
619+ char* showLogAfter;
620+ char countStr[WORDMAXLN];
621+
622+ /* get conf value for beginning day for listing */
623+ showLogAfter=GetConfValue("ShowLogAfter");
624+ if(isNull(showLogAfter)) return FALSE;
625+
626+ /* set default values */
627+ beginTime[0]='\0';
628+ endTime[0]='\0';
629+ *dateCount=0;
630+
631+ /* if do not get result yet */
632+ if(res==NULL){
633+
634+ /* prepare query string */
635+ /* select (adddate(now(), interval -1 month)),
636+ now(),
637+ datediff(now(),(adddate(now(), interval -1 month))) + 1; */
638+ snprintf(queryStr, BUFFMAXLN,
639+ "select (%s), now(), datediff(now(),(%s)) + 1",
640+ showLogAfter, showLogAfter);
641+
642+ /* send SQL query */
643+ if (mysql_query(&mysql, queryStr)){
644+ err_msg("ERR at %s#%d: mysql query[%s]: %s",__FILE__,__LINE__,queryStr,
645+ mysql_error(&mysql));
646+ return FALSE;
647+ }
648+
649+ /* store result */
650+ res = mysql_store_result(&mysql);
651+ }
652+
653+ /* output table name */
654+ row = mysql_fetch_row(res);
655+
656+ /* if found, return values */
657+ if(row!=NULL){
658+ strncpy(beginTime, row[0], WORDMAXLN);
659+ strncpy(endTime, row[1], WORDMAXLN);
660+ strncpy(countStr, row[2], WORDMAXLN);
661+ *dateCount=atoi(countStr);
662+ return TRUE;
663+ }
664+ /* if not found, free memory area */
665+ else{
666+ mysql_free_result(res);
667+ return FALSE;
668+ }
669+}
670+
611671 /********************************************
612672 routines for debugging output
613673 ********************************************/
@@ -721,13 +781,14 @@ int IsSessionFoundInMngDb(char* macAddr){
721781 return ret;
722782 }
723783
724-int GetNextUsageLogFromMngDb(char* userId, char* extraId, char* macAddr, char* deviceName, char* openTime, char* gatewayName, int* weekday){
784+int GetNextUsageLogFromMngDb(char* userId, char* extraId, char* macAddr,
785+ char* deviceName, char* openTime, char* closeTime, char* gatewayName){
725786 int ret;
726787 if(debug>1) err_msg("DEBUG:=>getNextUsageLogFromMngDb(%s,%s)",userId,extraId);
727788 ret=getNextUsageLogFromMngDb(userId,extraId,macAddr,deviceName,
728- openTime,gatewayName,weekday);
729- if(debug>1) err_msg("DEBUG:(%d)<=getNextUsageLogFromMngDb(,,%s,%s,%s,%s,%d)",
730- ret,macAddr,deviceName,openTime,gatewayName,*weekday);
789+ openTime,closeTime,gatewayName);
790+ if(debug>1) err_msg("DEBUG:(%d)<=getNextUsageLogFromMngDb(,,%s,%s,%s,%s,%s)",
791+ ret,macAddr,deviceName,openTime,closeTime,gatewayName);
731792 return ret;
732793 }
733794
@@ -739,3 +800,12 @@ int GetNextMailAddressFromMngDb(char* mailAddress, char* limitDate, char*device)
739800 ret,mailAddress,limitDate,device);
740801 return ret;
741802 }
803+
804+int GetTimeRangeToShowLog(char* beginTime, char* endTime, int* dateCount){
805+ int ret;
806+ if(debug>1) err_msg("DEBUG:=>getTimeRangeToShowLog( )");
807+ ret=getTimeRangeToShowLog(beginTime, endTime, dateCount);
808+ if(debug>1) err_msg("DEBUG:(%d)<=getTimeRangeToShowLog(%s,%s,%d)",
809+ ret,beginTime,endTime,*dateCount);
810+ return ret;
811+}
--- a/mngsrc/opengatemmng.h
+++ b/mngsrc/opengatemmng.h
@@ -189,8 +189,9 @@ int DelMacAddrFromMngDb(char* macAddr);
189189 int RenewMacAddrInMngDb(char* macAddr);
190190 int PauseMacAddrInMngDb(char* macAddr);
191191 int IsSessionFoundInMngDb(char* macAddr);
192-int GetNextUsageLogFromMngDb(char* userId, char* extraId, char* macAddr, char* deviceName, char* openTime, char* gatewayName, int* weekday);
192+int GetNextUsageLogFromMngDb(char* userId, char* extraId, char* macAddr, char* deviceName, char* openTime, char* closeTime, char* gatewayName);
193193 int GetNextMailAddressFromMngDb(char* mailAddress, char* limitDate, char*device);
194+int GetTimeRangeToShowLog(char* beginTime, char* endTime, int* dateCount);
194195
195196 /* workdb.c */
196197 int SetupSqliteBusyTimeoutValue(void);