OSDN Git Service

modified update page. reduced emails.
authorwatanaby <watanaby@users.sourceforge.net>
Thu, 26 Mar 2015 04:16:52 +0000 (13:16 +0900)
committerwatanaby <watanaby@users.sourceforge.net>
Thu, 26 Mar 2015 04:16:52 +0000 (13:16 +0900)
doc/Changes.html
html/en/macupdate.html
html/ja/macupdate.html
html/showlog.js
mngsrc/managementdb.c
mngsrc/opengatemmail.c

index fc62c08..6695988 100644 (file)
@@ -243,6 +243,10 @@ OpengateM History</H3>
        </DT><DD>
        Added sendreportmail.php cooperating with watch function of v0.9.1(phpsrc).
        </DD>
+       <DT>Ver.0.9.4 at 2015.3.26
+       </DT><DD>
+       Modified update page(opengatemup). Reduced emails(opengatemmail).
+       </DD>
 </DL>
 
 </BODY>
index 2e6eb0a..a038ff7 100644 (file)
@@ -11,7 +11,12 @@ var loglist={
 </script>
 <script type="text/javascript" src="/opengate/showlog.js"></script>
 <script type="text/javascript" src="/opengate/editstring.js"></script>
-</head>
+<script>
+function toggleDisplay(id){
+ if (document.getElementById(id).style.display=="none") document.getElementById(id).style.display="block";
+ else document.getElementById(id).style.display="none";
+}
+</script></head>
 <body align="center">
 
 <p><font size="5">Update of MAC address registration </font></p>
@@ -38,34 +43,44 @@ action="%%CGINAME%%?lang=en&redirectedurl=%%REDIRECTEDURL%%">
 </tr>
 %%MACLIST%%
 </table>
-<p><input type="submit" value=" Send "></p>
+<p><input type="submit" value=" Send ">
+<span style="color:blue;text-decoration:underline;" onclick="toggleDisplay('help1')"> help </span>
+</p>
 </form>
+
 <p><font color="red">
 %%ERRORLIST%%
 </font></p>
-<p>
-<p><strong>To prevent hijacking, please confirm your usage
-log.</strong> 
-The red border cells in the usage log include two or more records for one device. Please check carefully.
-</p>
 
-<p>Select <strong>Renew</strong> to renew the registration (resume
+<ul id="help1" style="display:none">
+<li>Select <strong>Renew</strong> to renew the registration (resume
 and extend the limit date). 
-</p>
-<p>
+</li>
+<li>
 Select <strong>Pause</strong> to pause the
 usage. If you want to reuse the device, check "Renew". 
-</p>
-<p>
+</li>
+<li>
 Select <strong>Delete</strong> to delete the registration. If you
 may use this terminal in the future, please use "Pause".
-</p>
-<p>
+</li>
+<li>
 The status "I" indicates that the device is set as Inactive by some
 reason. Please contact to the administrator.
+</li>
+</ul>
+
+<p><font size="5"> usage log </font><font size="3">(To prevent hijacking, please confirm your log.)</font>
+<span style="color:blue;text-decoration:underline;" onclick="toggleDisplay('help2')"> help </span>
 </p>
 
-<p><font size="5"> usage log </font></p>
+<ul id="help2" style="display:none">
+<li>The color-bars in the chart show the time range when you used your devices.</li>
+<li>If there is a use without your memory, please inform it to the administrator.</li>
+<li>The red frame indicates that one device has plural logs. Please check it carefully.</li>
+<li>Even if you do not intend to use the device, the automatic access might be done.</li>
+<li>The closing of the network has time delay after finishing the use.</li>
+</ul>
 
 <div id="usagelog"></div>
 <div id="popup"></div>
index c5f234b..da26d98 100644 (file)
@@ -11,6 +11,12 @@ var loglist={
 </script>
 <script type="text/javascript" src="/opengate/showlog.js"></script>
 <script type="text/javascript" src="/opengate/editstring.js"></script>
+<script>
+function toggleDisplay(id){
+ if (document.getElementById(id).style.display=="none") document.getElementById(id).style.display="block";
+ else document.getElementById(id).style.display="none";
+}
+</script>
 </head>
 <body align="center">
 <p><font size="5">MACアドレス登録更新</font></p>
@@ -38,27 +44,30 @@ action="%%CGINAME%%?lang=ja&redirectedurl=%%REDIRECTEDURL%%">
 %%MACLIST%%
 </table>
 
-<p><input type="submit" value=" 送信 "></p>
+<p><input type="submit" value=" 送信 ">
+<span style="color:blue;text-decoration:underline;" onclick="toggleDisplay('help1')"> help </span>
+</p>
 </form>
 
 <p><font color="red">
 %%ERRORLIST%%
 </font></p>
 
-<p><strong>不正利用を防ぐため、下の利用履歴が妥当か確認して下さい。
-</strong>利用履歴における赤枠セルは1つの機器に対する2つ以上の利用記録を含んでいます。特に注意して下さい。</p>
-
-<p><strong>「更新」</strong>をチェックすると、機器の登録を更新して利用期限を延長します。</p>
+<ul id="help1" style="display:none">
+<li><strong>「更新」</strong>をチェックすると、機器の登録を更新して利用期限を延長します。</li>
+<li><strong>「休止」</strong>をチェックすると、利用不可にします。再び利用するときには更新処理をしてください。</li>
+<li><strong>「削除」</strong>をチェックすると、機器の登録を削除します。再び利用する可能性があるときは、休止を利用下さい。</li>
+<li>状態が"I"となっている機器は無効とされています。理由は管理者に問い合わせ下さい。</li>
+</ul>
 
-<p><strong>「休止」</strong>をチェックすると、利用不可にします。再び利用するときには更新処理をしてください。
+<p><font size="5">利用履歴</font><font size="3">(不正利用を防ぐため、妥当か確認して下さい。)</font>
+<span style="color:blue;text-decoration:underline;" onclick="toggleDisplay('help2')"> help </span>
 </p>
-<p><strong>「削除」</strong>をチェックすると、機器の登録を削除します。
-再び利用する可能性があるときは、休止を利用下さい。
-</p>
-<p>状態が"I"となっている機器は無効とされています。理由は管理者に問い合わせ下さい。</p>
-
-
-<p><font size="5">利用履歴</font></p>
+<ul id="help2" style="display:none">
+<li>利用された時間帯を1時間ごとに色付け表示しています。覚えの無い履歴があれば管理者までお知らせください。</li>
+<li>赤枠の時間帯は1つの機器に対する2つ以上の履歴を含んでいます。特に注意下さい。</li>
+<li>意図して利用しなくても、自動通信による利用がありえます。また使い終わってしばらくしてから閉鎖します。</li>
+</ul>
 
 <div id="usagelog"></div>
 <div id="popup"></div>
index e95836c..3c908b9 100644 (file)
@@ -168,13 +168,13 @@ function setupCellProperties(td, date, time, iDevice){
        //set background color of the cell\r
        //if two or more items are found, display red border\r
        if(logItemNo.length > 1){\r
-               td.style.background=colorList[iDevice];\r
+               td.style.background=colorList[iDevice%5];\r
                td.style.border="3px solid Red";\r
        }\r
        // one item is found (if the item number == -1, no log is matched)\r
        else if(logItemNo.length == 1){\r
                if(logItemNo[0] == -1)  td.style.background=colorList["none"];\r
-               else td.style.background=colorList[iDevice];\r
+               else td.style.background=colorList[iDevice%5];\r
        }\r
        // no item\r
        else td.style.background=colorList["blank"];\r
@@ -239,7 +239,7 @@ function makeDevicesLegend() {
             tr.appendChild(td);\r
             var td = document.createElement("td");\r
             td.width=50;\r
-            td.style.background=colorList[iDevice];\r
+            td.style.background=colorList[iDevice%5];\r
             tr.appendChild(td);\r
             tbody.appendChild(tr);\r
         }\r
index 356da87..3ac08ae 100644 (file)
@@ -574,10 +574,11 @@ int getNextMailAddressFromMngDb(char* mailAddress, char* limitDate, char* device
     /* [select mailAddress,limitDate,device from macaddrs 
         where (  date(now())=date(adddate(limitDate, interval -1 day)) 
               OR date(now())=date(adddate(limitDate, interval -7 day))  ) 
-             AND (status='A' OR status='P')] */
+             AND (status='A' OR status='P') order by mailAddress,limitDate] */
     snprintf(queryStr, BUFFMAXLN, 
             "select mailAddress,limitDate,device from macaddrs "
-            " where (%s) and (status='A' or status='P')", mailTiming);
+            " where (%s) and (status='A' or status='P') "
+            " order by mailAddress,limitDate", mailTiming);
     /*       mailTiming is a condition string defined in conf file */ 
 
     /* send SQL query */
index a576bcc..7414e52 100644 (file)
@@ -29,9 +29,12 @@ Email: watanaby@is.saga-u.ac.jp
 /***************************************************/
 int  main(int argc, char **argv)
 {
-  char mailAddress[BUFFMAXLN]; /* mail address */
-  char limitDate[WORDMAXLN]; /* limit date */
-  char device[WORDMAXLN]; /* device name */
+  char mailAddress[BUFFMAXLN]=""; /* mail address */
+  char limitDate[WORDMAXLN]=""; /* limit date */
+  char device[WORDMAXLN]=""; /* device name */
+  char deviceList[BUFFMAXLN]=""; /* device name list */
+  char mailAddressPrev[BUFFMAXLN]=""; /* mail address of previous record */
+  char limitDatePrev[WORDMAXLN]=""; /* limit date of previous record */
   int count=0;   /* count for sending mails */
   char* progName; /* the name of this program in argv[0] */
 
@@ -67,9 +70,51 @@ int  main(int argc, char **argv)
   InitConf();
   if(!InitMngDb()) return 0;
 
-  /* get mail address for users near expiration date and send mail */
-  while(GetNextMailAddressFromMngDb(mailAddress, limitDate, device)){
-    if(SendMail(mailAddress, limitDate, device)) count++;
+  /* get first mail address near expiration date */
+  if(GetNextMailAddressFromMngDb(mailAddress, limitDate, device)){
+
+    /* if get, save the first record */
+    strncpy(mailAddressPrev, mailAddress, BUFFMAXLN);
+    strncpy(limitDatePrev, limitDate, WORDMAXLN);
+    strncpy(deviceList, device, WORDMAXLN);
+
+    /* get next mail address near expiration date */
+    while(GetNextMailAddressFromMngDb(mailAddress, limitDate, device)){
+
+      /* if mailAddress or limitDate are not same as previous */
+      if( strcmp(mailAddress, mailAddressPrev)!=0 
+        || strcmp(limitDate, limitDatePrev)!=0 ){
+
+       /* send mail to the address and clear deviceList */
+       if(!isNull(mailAddressPrev)){
+         if(SendMail(mailAddressPrev, limitDatePrev, deviceList)) count++;
+       }
+       deviceList[0]='\0';
+      }
+
+      /* save the mail Address and limit date */
+      strncpy(mailAddressPrev, mailAddress, BUFFMAXLN);
+      strncpy(limitDatePrev, limitDate, WORDMAXLN);
+
+      /* add the device name to the deviceList
+       if list is too long, it is terminated by ", ......" */
+      if(isNull(deviceList)){
+       strncpy(deviceList, device, WORDMAXLN);
+      }
+      else if(strstr(deviceList, ", ......")!=NULL) ;
+      else if( strlen(deviceList) > BUFFMAXLN*0.8 ){
+       strncat(deviceList, ", ......", BUFFMAXLN); 
+      }
+      else{
+       strncat(deviceList, ", ", BUFFMAXLN); 
+       strncat(deviceList, device, BUFFMAXLN);
+      }
+    }
+
+    /* post process at the end of get loop */
+    if( !isNull(mailAddressPrev) ){
+      if(SendMail(mailAddressPrev, limitDatePrev, deviceList)) count++;
+    }
   }
 
   /* finalize */