OSDN Git Service

modified code to prevent DB inflation
authorwatanaby <watanaby@users.osdn.jp>
Sun, 19 Jun 2016 08:06:50 +0000 (17:06 +0900)
committerwatanaby <watanaby@users.osdn.jp>
Sun, 19 Jun 2016 08:06:50 +0000 (17:06 +0900)
22 files changed:
conf/opengatemmng.conf.sample
doc/Changes.html
html/en/macchk.html
html/en/macreg.html
html/en/macupdate.html
html/ja/macchk.html
html/ja/macreg.html
html/ja/macupdate.html
html/showlog.js [deleted file]
mdsrc/managementdb.c
mdsrc/opengatemd.c
mdsrc/opengatemd.h
mdsrc/session.c
mdsrc/workdb.c
mngsrc/cgi.c
mngsrc/managementdb.c
mngsrc/opengatemmng.h
phpsrc/sendreportmail.php
phpsrc/showlog.php [deleted file]
phpsrc/showtable.php
sqlscript/createtablescript
sqlscript/updatescript4 [deleted file]

index 58d1fcf..72bda17 100644 (file)
                <Address>{-hostname-|-ip_address-}</Address>
                [ <Port>-portno-</Port> ]
                [ <Timeout>-seconds-</Timeout> ]
-               [<MailDomain>-mail-address-after-@-</MainDomain>]
+               [<MailDomain>-mail-address-after-@-</MailDomain>]
        </AuthServer>
        #   AuthOK, if request by <Protocol> is accepted by <Address>.
        #   Address is FQDN or IP address       
                <Protocol>pam</Protocol>
                [ <ServiceName>-servicename_in_pam_conf-</ServiceName> ]
                [ <Timeout>-second-</Timeout> ]
-               [<MailDomain>-mail-address-after-@-</MainDomain>]
+               [<MailDomain>-mail-address-after-@-</MailDomain>]
        </AuthServer>
        #   Auth by PAM
        #   If not define <ServiceName>, "opengate" is used in "pam.conf".
                <Protocol>radius</Protocol>
                [ <ConfFile>-path_to_radius_conf-</ConfFile> ]
                [ <Timeout>-second-</Timeout> ]
-               [<MailDomain>-mail-address-after-@-</MainDomain>]
+               [<MailDomain>-mail-address-after-@-</MailDomain>]
        </AuthServer>
        #   Auth by RADIUS
        #   If not define <ConfigFile>, "/etc/radius.conf" is used.
                <Uri>-uri-of-ldap-server-</Uri>
                <BaseDN>-ldap_base_dn_to_search-</BaseDN>
                [ <Timeout>-second-</Timeout> ]
-               [<MailDomain>-mail-address-after-@-</MainDomain>]
+               [<MailDomain>-mail-address-after-@-</MailDomain>]
        </AuthServer>
        #   Auth by LDAP/LDAPS
        #   Uri examples
        #### TYPE 5 (ACCEPT or DENY) ####
        <AuthServer>
                <Protocol>{accept|deny}</Protocol>
-               [<MailDomain>-mail-address-after-@-</MainDomain>]
+               [<MailDomain>-mail-address-after-@-</MailDomain>]
        </AuthServer>
        #   The user is accepted or denied without inquiring auth.
        #   ***This setting is prepared for debugging***
                [<OrgAttribute>-env-vars-for-uid-</OrgAttribute>]
                [<EppnAttribute>-env-vars-for-eppn-</EppnAttribute>]
                [<MailAttribute>-env-vars-for-mail-address-</MailAttribute>]
-               [<MailDomain>-mail-address-after-@-</MainDomain>]
+               [<MailDomain>-mail-address-after-@-</MailDomain>]
         </AuthServer>
        #   Auth by Shibboleth
 
        #### TYPE 7 (Http Basic) ####
        <AuthServer>
                 <Protocol>httpbasic</Protocol>
-               [<MailDomain>-mail-address-after-@-</MainDomain>]
+               [<MailDomain>-mail-address-after-@-</MailDomain>]
         </AuthServer>
        #   Auth by http-basic
        #   Set 'opengatemXXX.cgi' as 'Basic' in .htaccess
                <Protocol>pop3s</Protocol>
                <Address>pop.saga-u.ac.jp</Address>
                <Timeout>30</Timeout>
-               <MailDomain>og.saga-u.ac.jp</MainDomain>
+               <MailDomain>og.saga-u.ac.jp</MailDomain>
        </AuthServer>
 
        <AuthServer>
                <Uri>ldaps://ldap.saga-u.ac.jp</Uri>
                <BaseDN>ou=people,dc=saga-u,dc=ac,dc=jp</BaseDN>
                <Timeout>5</Timeout>
-               <MailDomain>og.saga-u.ac.jp</MainDomain>
+               <MailDomain>og.saga-u.ac.jp</MailDomain>
        </AuthServer>
 
        <AuthServer>
                <Address>192.168.0.1</Address>
                <Protocol>ftpsi</Protocol>
                <Timeout>15</Timeout>
-               <MailDomain>og.saga-u.ac.jp</MainDomain>
+               <MailDomain>og.saga-u.ac.jp</MailDomain>
        </AuthServer>
 
        <AuthServer>
                <Protocol>radius</Protocol>
-               <MailDomain>og.saga-u.ac.jp</MainDomain>
+               <MailDomain>og.saga-u.ac.jp</MailDomain>
        </AuthServer>
 
        <AuthServer>
                <Protocol>pam</Protocol>
-               <MailDomain>og.saga-u.ac.jp</MainDomain>
+               <MailDomain>og.saga-u.ac.jp</MailDomain>
        </AuthServer>
 
        <AuthServer>
 
        <AuthServer>
                <Protocol>httpbasic</Protocol>
-               <MailDomain>og.saga-u.ac.jp</MainDomain>
+               <MailDomain>og.saga-u.ac.jp</MailDomain>
        </AuthServer>
 
 -->
index 73bae7b..5426506 100644 (file)
@@ -271,6 +271,10 @@ OpengateM History</H3>
        </DT><DD>
        Added warning message at registrating other user's device (openatem-all).
        </DD>
+       <DT>Ver.1.1.0 at 2016.6.19
+       </DT><DD>
+        Modified code to prevent inflation of Databases (drop table macippair&sessionmd:MySQL, delete old records of macmodify:MySQL and macinfo:SQLite3).
+w      </DD>
 </DL>
 <P>
 <B>Please see GIT on osdn.jp to check the differences between versions.</B> 
index 4ebbab9..aeaae7b 100644 (file)
 <hr>
 <p>
 How to use
-<ol>
-<li>Connect the target terminal to the access point of this page, and
-try network access to confirm that the network for the terminal is closed.
-<li>Load this page. If you already loaded, reload it.
-<li>The above is the list of addresses using this access point. The top of the list is the one detected most recently.
-<li>Choose an address in the list and push the "open" button. When a server replies, a timer starts.
-<li>Try to use the network at the target terminal.
-<li>If the network is not available, push "close" button and try other address.
-<li>If the network is available, push "close" button and confirm that the network is not available. Then push "register" button to jump to the registration page.
-</ol>
+<table width=800 cellspacing=6>
+  <tr><td>1.</td>
+    <td>
+      Connect the target terminal to the access point, and
+      try network access to confirm that the network for the terminal is closed.
+    </td>
+  </tr>
+  <tr><td>2.</td>
+    <td>
+      Load this page. If you already loaded, reload it.
+    </td>
+  </tr>
+  <tr><td>3.</td>
+    <td>
+      The above is the list of addresses using this access point.
+      The top of the list is the one detected most recently.
+    </td>
+  </tr>
+  <tr><td>4.</td>
+    <td>
+      Choose an address in the list and push the "open" button.
+    </td>
+  </tr>
+  <tr><td>5.</td>
+    <td>
+      When the server replies, the timer starts.
+    </td>
+  </tr>
+  <tr><td>6.</td>
+    <td>
+      Try to use the network at the target terminal.
+    </td>
+  </tr>
+  <tr><td>7.</td>
+    <td>
+      If the network is not available, push "close" button and try other address
+    </td>
+  </tr>
+  <tr><td>8.</td>
+    <td>
+      If the network is available, push "close" button and confirm that the network is not available.
+      Then push "register" button to jump to the registration page.
+    </td>
+  </tr>
+</table>
 </p>
 <p>
 Warning
-<ul>
-<li>When the timer does not start, contact an administrator, as the server might be malfunction.
-<li>The network is closed soon, even if you do not push the "close" button.
-However, it is desirable to close the network early with the "close" button.
-</ul>
+<table width=800 cellspacing=6>
+  <tr><td>
+      When the timer does not start, contact an administrator.
+      The server might be malfunction.
+  </td></tr>
+  <tr><td>
+      The network is closed soon, even if you do not push the "close" button.
+      However, it is desirable to close the network early with the "close" button.
+      </td></tr>
+</table>
 </p>
 </center>
 </body>
index abcb968..09ac0bf 100644 (file)
@@ -1,6 +1,12 @@
 <html>
 <head>
-<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+  <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>
 <title></title>
 </head>
 <body>
   </tr>
 </table>
 
-<p><input type="submit" value=" Register "></p>
+<p><input type="submit" value=" Register ">
+  <span style="color:blue;text-decoration:underline;" onclick="toggleDisplay('help1')"> help </span>
+</p>
 </form>
 
 <p><font color="red">
 %%ERRORLIST%%
 </font></p>
 
-<ol>
-<li>After registration, you can use network without password in this
-month (next month, when registered in the latter half of the
-month).</li> 
-<li>Before the limit date, a warning mail will be sent to
-the above mail address. If the mail address has an error, you can not
-receive the mail. Please check the address and correct it. Or if you
-don't need the mail, delete it.</li> 
-<li>Please enter the name of your
-device in the above yellow area(e.g., iPadX, X-01A, TabletAZ).</li>
-<li>You can register %%MAXDEVICES%% devices.</li> 
-<li>After
-registration, exit this browser to reset authentication state.</li>
-</ol>
+<table width=800 cellpadding=6 id="help1" style="display:none">
+  <tr><td>
+      After registration, you can use network without password in this
+      month (next month, when registered in the latter half of the
+      month).
+  </td></tr>
+  <tr><td>
+      Before the limit date, a warning mail will be sent to
+      the above mail address. If the mail address has an error, you can not
+      receive the mail. Please check the address and correct it. Or if you
+      don't need the mail, delete it.
+  </td></tr>
+  <tr><td>
+      Please enter the name of your
+      device in the above yellow area(e.g., iPadX, X-01A, TabletAZ).
+  </td></tr>
+  <tr><td>
+      You can register %%MAXDEVICES%% devices.
+  </td></tr>
+  <tr><td>
+      After registration, exit this browser to reset authentication state.
+  </td></tr>
+</table>
 
+<div style="%%LISTDISPLAYSTYLE%%">
 <p><font size=+1>Registered Terminals</font></p>
 <p>
 <table border='1'>
@@ -63,6 +81,7 @@ registration, exit this browser to reset authentication state.</li>
 %%MACREGLIST%%
 </table>
 </p>
+</div>
 
 <p>
 <a href=opengatemup.cgi?lang=en>Update Page</a>
index 586dccf..95dc84a 100644 (file)
@@ -2,21 +2,14 @@
 <head>
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
 <title></title>
-<script type="text/javascript">
-<!--
-var loglist={
-%%USAGELOG%%
-};
--->
-</script>
-<script type="text/javascript" src="/opengate/showlog.js"></script>
-<script type="text/javascript" src="/opengate/editstring.js"></script>
+<script type="text/javascript" src="/opengate/editstring.js"/>
 <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>
+</script>
+</head>
 <body>
 <center>
 
@@ -53,41 +46,27 @@ action="%%CGINAME%%?lang=en&redirectedurl=%%REDIRECTEDURL%%">
 %%ERRORLIST%%
 </font></p>
 
-<ul id="help1" style="display:none">
-<li>Select <strong>Renew</strong> to renew the registration (resume
-and extend the limit date). 
-</li>
-<li>
-Select <strong>Pause</strong> to pause the
-usage. If you want to reuse the device, check "Renew". 
-</li>
-<li>
-Select <strong>Delete</strong> to delete the registration. If you
-may use this terminal in the future, please use "Pause".
-</li>
-<li>
-The status <strong>I</strong> indicates that the device is set as Inactive by some
-reason. Please contact to the administrator.
-</li>
-<li>
-The <strong>Device Name</strong> and <strong>Mail Address</strong> can be modified by clicking them.
-</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>
-
-<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>
+<table width=800 cellpadding=6 id="help1" style="display:none">
+  <tr><td>
+      Select "Renew" to renew the registration (resume
+      and extend the limit date).
+  </td></tr>
+  <tr><td>
+      Select "Pause" to pause the
+      usage. If you want to reuse the device, check "Renew".
+  </td></tr>
+  <tr><td>
+      Select "Delete" to delete the registration. If you
+      may use this terminal in the future, please use "Pause".
+  </td></tr>
+  <tr><td>
+      The status "I" indicates that the device is set as
+      Inactive by some reason. Please contact to the administrator.
+  </td></tr>
+  <tr><td>
+      The values of "Device Name" and "Mail Address" in the table can be modified by clicking them.
+  </td></tr>
+</table>
 
 </center>
 </body>
index c839134..c433eeb 100644 (file)
 <hr>
 <p>
 使用方法
-<ol>
-<li>登録を希望する端末で、この端末と同じアクセスポイントに接続して、ネッ
-トワークアクセスを試み、ネットワークが閉鎖していることを確認する。
-<li>このページを表示する。確認前に表示しているときはリロードを行う。
-<li>上記の表は、同一アクセスポイントを最近利用した端末のアドレス一覧である。リストの先頭が最も最近に検出した端末である。
-<li>登録希望端末と予想されるアドレスを選択して「開放」ボタンを押す。
-<li>サーバが応答して、ネットワークを開放すると、タイマーが始動する。
-<li>タイマー作動中に、登録希望端末でネットワークを利用してみる。
-<li>利用が不可であれば、「閉鎖」ボタンで閉鎖して、別のアドレスを試す。
-<li>利用が可能であれば、「閉鎖」ボタンで閉鎖して、利用が不可に戻ることを確認し、「登録」ボタンで登録ページへ移行する。
-</ol>
+<table width=800 cellspacing=6>
+  <tr><td>1.</td>
+    <td>
+      登録を希望する端末で、この端末と同じアクセスポイントに接続して、ネットワークアクセスを試み、ネットワークが閉鎖していることを確認する。
+    </td>
+  </tr>
+  <tr><td>2.</td>
+    <td>
+      このページを表示する。確認前に表示しているときはリロードを行う。
+    </td>
+  </tr>
+  <tr><td>3.</td>
+    <td>
+      上記の表は、同一アクセスポイントを最近利用した端末のアドレス一覧である。リストの先頭が最も最近に検出した端末である。
+    </td>
+  </tr>
+  <tr><td>4.</td>
+    <td>
+      登録希望端末と予想されるアドレスを選択して「開放」ボタンを押す。
+    </td>
+  </tr>
+  <tr><td>5.</td>
+    <td>
+      サーバが応答して、ネットワークを開放すると、タイマーが始動する。
+    </td>
+  </tr>
+  <tr><td>6.</td>
+    <td>
+      タイマー作動中に、登録希望端末でネットワークを利用してみる。
+    </td>
+  </tr>
+  <tr><td>7.</td>
+    <td>
+      利用が不可であれば、「閉鎖」ボタンで閉鎖して、別のアドレスを試す。
+    </td>
+  </tr>
+  <tr><td>8.</td>
+    <td>
+      利用が可能であれば、「閉鎖」ボタンで閉鎖して、利用が不可に戻ることを確認し、「登録」ボタンで登録ページへ移行する。
+    </td>
+  </tr>
+</table>
 </p>
 <p>
 注意事項
-<ul>
-<li>タイマーが始動しない場合はサーバ不調の可能性があるので、管理者に連絡すること。
-<li>「閉鎖」ボタンを押さなくてもネットワークは時間切れで閉鎖される。開放のままページ移行しても問題ない。しかし「閉鎖」ボタンで早期に閉鎖することが望ましい。
-</ul>
+<table width=800 cellspacing=6>
+  <tr><td>
+      タイマーが始動しない場合はサーバ不調の可能性があるので、管理者に連絡すること。
+  </td></tr>
+  <tr><td>
+      「閉鎖」ボタンを押さなくてもネットワークは時間切れで閉鎖される。開放のままページ移行しても問題ない。しかし「閉鎖」ボタンで早期に閉鎖することが望ましい。
+  </td></tr>
+</table>
 </p>
 </center>
 </body>
index 75bb8a9..cdaa13b 100644 (file)
@@ -1,6 +1,12 @@
 <html>
 <head>
-<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+  <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>
 <title></title>
 </head>
 <body>
   </tr>
 </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>
 
-<ol>
-<li>端末を登録すると今月末(月の後半登録では翌月末)までパスワード入力なしで利用できます。</li>
-<li>期限前には、上記メールアドレスに警告メールが届きます。設定が間違っ
-ていると届きませんので、確認して正しいアドレスに修正してください。メー
-ルが不要ならば削除してください。</li> 
-<li>機器名には端末を識別できる名前を入れてください。
-漢字は不可です(例:iPadX, X-01A, TabletAZ)。 </li>
-<li>登録は一人当り%%MAXDEVICES%%台までです。</li>
-<li>登録が終ったら認証状態をリセットするためにブラウザを終了して下さい。
-</li>
-</ol>
+<table width=800 cellpadding=6 id="help1" style="display:none">
+  <tr><td>
+      端末を登録すると今月末(月の後半登録では翌月末)までパスワード入力なしで利用できます。
+  </td></tr>
+  <tr><td>  
+      期限前には、上記メールアドレスに警告メールが届きます。設定が間違っ
+      ていると届きませんので、確認して正しいアドレスに修正してください。メー
+      ルが不要ならば削除してください。
+  </td></tr>
+  <tr><td>
+      機器名には端末を識別できる名前を入れてください。
+      漢字は不可です(例:iPadX, X-01A, TabletAZ)。
+  </td></tr>
+  <tr><td>
+      登録は一人当り%%MAXDEVICES%%台までです。
+  </td></tr>
+  <tr><td>
+      登録が終ったら認証状態をリセットするためにブラウザを終了して下さい。
+  </td></tr>
+</table>
 
+<div style="%%LISTDISPLAYSTYLE%%">
 <p><font size=+1>既登録端末</font></p>
 <p>
 <table border='1'>
@@ -60,7 +78,7 @@
 %%MACREGLIST%%
 </table>
 </p>
-
+</div>
 
 <p>
 <a href=opengatemup.cgi?lang=ja>登録更新ページ</a>
index 25564f2..963151e 100644 (file)
@@ -2,15 +2,7 @@
 <head>
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
 <title></title>
-<script type="text/javascript">
-<!--
-var loglist={
-%%USAGELOG%%
-};
--->
-</script>
-<script type="text/javascript" src="/opengate/showlog.js"></script>
-<script type="text/javascript" src="/opengate/editstring.js"></script>
+<script type="text/javascript" src="/opengate/editstring.js"/>
 <script>
 function toggleDisplay(id){
  if (document.getElementById(id).style.display=="none") document.getElementById(id).style.display="block";
@@ -54,25 +46,24 @@ action="%%CGINAME%%?lang=ja&redirectedurl=%%REDIRECTEDURL%%">
 %%ERRORLIST%%
 </font></p>
 
-<ul id="help1" style="display:none">
-<li><strong>「更新」</strong>をチェックすると、機器の登録を更新して利用期限を延長します。</li>
-<li><strong>「休止」</strong>をチェックすると、利用不可にします。再び利用するときには更新処理をしてください。</li>
-<li><strong>「削除」</strong>をチェックすると、機器の登録を削除します。再び利用する可能性があるときは、休止を利用下さい。</li>
-<li>「状態」が<strong> I </strong>となっている機器は無効とされています。理由は管理者に問い合わせ下さい。</li>
-<li><strong>機器名</strong>と<strong>メールアドレス</strong>は、クリックして変更できます。</li></ul>
-
-<p><font size="5">利用履歴</font><font size="3">(不正利用を防ぐため、妥当か確認して下さい。)</font>
-<span style="color:blue;text-decoration:underline;" onclick="toggleDisplay('help2')"> help </span>
-</p>
-<ul id="help2" style="display:none">
-<li>利用された時間帯を1時間ごとに色付け表示しています。覚えの無い履歴があれば管理者までお知らせください。</li>
-<li>赤枠の時間帯は1つの機器に対する2つ以上の履歴を含んでいます。特に注意下さい。</li>
-<li>意図して利用しなくても、自動通信による利用がありえます。また使い終わってしばらくしてから閉鎖します。</li>
-</ul>
+<table width=800 cellpadding=6 id="help1" style="display:none">
+  <tr><td>
+      「更新」をチェックすると、機器の登録を更新して利用期限を延長します。
+  </td></tr>
+  <tr><td>
+      「休止」をチェックすると、利用不可にします。再び利用するときには更新処理をしてください。
+  </td></tr>
+  <tr><td>
+      「削除」をチェックすると、機器の登録を削除します。再び利用する可能性があるときは、休止を利用下さい。
+  </td></tr>
+  <tr><td>
+      「状態」が”I”となっている機器は無効とされています。理由は管理者に問い合わせ下さい。
+  </td></tr>
+  <tr><td>
+      「機器名」と「メールアドレス」の値は、クリックして変更できます。
+  </td></tr>
+</table>
 
-<div id="usagelog"></div>
-<div id="popup"></div>
-<p><br><br></p>
 </center>
 </body>
 </html>
diff --git a/html/showlog.js b/html/showlog.js
deleted file mode 100644 (file)
index 6668b45..0000000
+++ /dev/null
@@ -1,315 +0,0 @@
-// Program to show chart type opengatem usage log in web page\r
-// used in macupdate.html in lang(ja/en) directory\r
-//\r
-//  Programmed by Yoshiaki Watanabe, 2013\r
-//  Revised by Minoru Kishira, 2013\r
-//\r
-// canvas.js by Satoru Takabayashi is used partially.\r
-//  http://0xcc.net/blog/archives/canvas.js\r
-//\r
-// You can redistribute it and/or modify it under the terms of \r
-// the GNU General Public License version 2.\r
-//\r
-\r
-// variables\r
-var nTime=24; // time division per day\r
-var beginTime;\r
-var endTime;\r
-var cellWidth="20px";\r
-var cellHeight="8px";\r
-var deviceList=[]; // devices used\r
-\r
-var colorList={0:"LimeGreen", 1:"Orange", 2:"SkyBlue", 3:"Tan", 4:"Thistle",\r
-        "none":"WhiteSmoke", "sunday":"Pink","saturday":"LightBlue", "blank":"white", "popup":"yellow"};\r
-var weekString = new Array("Sun","Mon","Tue","Wed","Thu","Fri","Sat");\r
-var today = new Date();\r
-var weekday;\r
-var monthday;\r
-\r
-////////////////////////////\r
-// make handler of mouseover\r
-function onmouseoverHandler(element, logItemNo) {\r
-\r
-    // save local values\r
-    var day=monthday;\r
-    var week=weekday;\r
-\r
-    // return the mandler \r
-    return function(e) {\r
-    \r
-    // if log item is found, show the item as popup\r
-    if(logItemNo[0]>=0){\r
-\r
-               // popup style\r
-               popup.style.position = "fixed"; \r
-               popup.style.left = e.clientX+20; \r
-               popup.style.top  = e.clientY+10; \r
-               popup.style.background = colorList["popup"]; \r
-               popup.style.display = "block";\r
-\r
-               // popup string\r
-               popup.innerHTML=loglist[logItemNo[0]].device +" ["+loglist[logItemNo[0]].macAddress+"]<BR>";\r
-               for(var i=0; i<logItemNo.length; i++){\r
-                       popup.innerHTML+="Used at "+ loglist[logItemNo[i]].gateway+"<BR>"\r
-                               +"( "+loglist[logItemNo[i]].openTime+" -> "+loglist[logItemNo[i]].closeTime+" )<BR>";\r
-                       }\r
-        }\r
-    }\r
-}\r
-\r
-////////////////////////////\r
-// make handler of mouseout\r
-function onmouseoutHandler(element) {\r
-\r
-    // off the display\r
-    return function() {\r
-        popup.style.display = "none";\r
-    }\r
-}\r
-\r
-////////////////////////////\r
-// make cells to show every date-time range\r
-function makeCells() {\r
-\r
-    // make html table\r
-    var table = document.createElement("table");\r
-    var tbody = document.createElement("tbody");\r
-    table.border ="2px #808080 solid";\r
-\r
-    // grouping columns (title, 0-5, 6-11, 12-17, 18-23 hours)\r
-    table.rules ="groups";\r
-    cgroup0=document.createElement("colgroup"); cgroup0.span=1; table.appendChild(cgroup0);\r
-    cgroup1=document.createElement("colgroup"); cgroup1.span=6; table.appendChild(cgroup1);\r
-    cgroup2=document.createElement("colgroup"); cgroup2.span=6; table.appendChild(cgroup2);\r
-    cgroup3=document.createElement("colgroup"); cgroup3.span=6; table.appendChild(cgroup3);\r
-    cgroup4=document.createElement("colgroup"); cgroup4.span=6; table.appendChild(cgroup4);\r
-\r
-    // add header to display the hours\r
-    tbody.appendChild(makeHeaderRow());\r
-\r
-    // make row for each day and each device \r
-       var nDate=loglist["info"].dateCount;\r
-       var nDevice=deviceList.length;\r
-    for (var date = 0; date < nDate; date++) {\r
-        for(var iDevice = 0; iDevice < nDevice+1; iDevice++){\r
-            var tr = document.createElement("tr");\r
-\r
-            // make leftmost title column spanning 6 rows\r
-            if(iDevice==0) tr.appendChild(makeHeaderColumn(date));\r
-\r
-            // make column representing 0 hour to 23 hour\r
-            for (var time = 0; time < nTime; time++) {\r
-                var td = document.createElement("td");\r
-                setupCellProperties(td, date, time, iDevice);\r
-                if(iDevice==nDevice) td.style.background=colorList["blank"];\r
-                tr.appendChild(td);\r
-            }\r
-\r
-            tbody.appendChild(tr);\r
-        }\r
-    }\r
-    table.appendChild(tbody);\r
-    return table;\r
-}\r
-\r
-////////////////////////////\r
-// make the top title row to display hours\r
-function makeHeaderRow(){\r
-    var tr = document.createElement("tr");\r
-    var td = document.createElement("td");\r
-    tr.appendChild(td);\r
-    for (var time = 0; time < nTime; time++) {\r
-        var td = document.createElement("td");\r
-        var text = document.createTextNode(time);\r
-        td.appendChild(text);\r
-        tr.appendChild(td);\r
-    }\r
-    return tr;\r
-}\r
-\r
-////////////////////////////\r
-// make the leftmost title comumn spanning to all devices row\r
-function makeHeaderColumn(date){\r
-    var td = document.createElement("td");\r
-       var nDevice=deviceList.length;\r
-\r
-    td.rowSpan=nDevice+1;\r
-    dateStr=getRealDate(date);\r
-    var text = document.createTextNode(dateStr);\r
-    td.appendChild(text);\r
-    if(dateStr.indexOf(weekString[0])!=-1)\r
-        td.style.background=colorList["sunday"];\r
-    else if(dateStr.indexOf(weekString[6])!=-1)\r
-        td.style.background=colorList["saturday"];\r
-    return td;\r
-}\r
-\r
-////////////////////////////\r
-// get the real date string from date number(0 means begin date)\r
-function getRealDate(date){\r
-    var beginTime=new Date(loglist["info"].beginTime.replace(/-/g, "/"));\r
-    var y=beginTime.getFullYear();\r
-    var m=beginTime.getMonth();\r
-    var d=beginTime.getDate();\r
-    var realDate = new Date(y, m, d+date);\r
-    return (realDate.getMonth()+1)+"/"+realDate.getDate()+" "+ weekString[realDate.getDay()];\r
-}\r
-\r
-////////////////////////////\r
-// setup cell properties\r
-function setupCellProperties(td, date, time, iDevice){\r
-\r
-    td.width=cellWidth; td.height=cellHeight;\r
-\r
-    // search log for the time range;\r
-       var logItemNo = searchLog(date, time, iDevice);\r
-\r
-    td.onmouseover = onmouseoverHandler(td, logItemNo);\r
-    td.onmouseout = onmouseoutHandler(td);\r
\r
-       //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%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%5];\r
-       }\r
-       // no item\r
-       else td.style.background=colorList["blank"];\r
-}\r
-\r
-////////////////////////////\r
-// search the usage log corresponding to to the time range and the device number\r
-function searchLog(date, hour, iDevice){\r
-\r
-    var y=beginTime.getFullYear();\r
-    var m=beginTime.getMonth();\r
-    var d=beginTime.getDate();\r
-\r
-    var timeRangeBegin = new Date(y, m, d+date, hour);\r
-    var timeRangeEnd = new Date(y, m, d+date, hour+1);\r
-\r
-    // omit the range before beginTime or after endTime\r
-    if(timeRangeEnd < beginTime || endTime < timeRangeBegin) return -2;\r
-\r
-    // make the week number and month/date string\r
-    weekday=timeRangeBegin.getDay();\r
-    monthday=timeRangeBegin.getFullYear()+"/"+(timeRangeBegin.getMonth()+1)+"/"+timeRangeBegin.getDate();\r
-\r
-    // search the device in loglist \r
-    var logItemNoArray = new Array();\r
-    \r
-    nList=loglist["info"].listCount;\r
-    for (var i=0; i<nList; i++){\r
-        if(deviceList[iDevice] == loglist[i].device){\r
-\r
-            // loglist includes '2000-10-10 00:00:00' but Date() reads '2000/10/10 00:00:00'\r
-            var openTime = new Date(loglist[i].openTime.replace(/-/g, "/"));\r
-            var closeTime = new Date(loglist[i].closeTime.replace(/-/g, "/"));\r
-\r
-            // if the device is used in the time range, return the log item number\r
-            // second line check the device not closed yet\r
-            if(timeRangeBegin < closeTime && openTime < timeRangeEnd) logItemNoArray.push(i);\r
-            \r
-            if(loglist[i].closeTime=="0000-00-00 00:00:00" && openTime < timeRangeEnd) logItemNoArray.push(i);\r
-        }\r
-    }\r
-\r
-    // cannot found\r
-    if(logItemNoArray.length==0) logItemNoArray.push(-1);\r
-    return logItemNoArray;\r
-}\r
-\r
-////////////////////////////\r
-// make table for the legend of devices\r
-function makeDevicesLegend() {\r
-\r
-    var table = document.createElement("table");\r
-    table.border ="2px #808080 solid";\r
-    var tbody = document.createElement("tbody");\r
-       var nDevice=deviceList.length;\r
-\r
-    if(nDevice>0){\r
-        for (var iDevice = 0; iDevice<nDevice; iDevice++) {\r
-            var tr = document.createElement("tr");\r
-            var td = document.createElement("td");\r
-            td.innerHTML=deviceList[iDevice];\r
-            tr.appendChild(td);\r
-            var td = document.createElement("td");\r
-            td.width=50;\r
-            td.style.background=colorList[iDevice%5];\r
-            tr.appendChild(td);\r
-            tbody.appendChild(tr);\r
-        }\r
-    }else{\r
-        var tr = document.createElement("tr");\r
-        var td = document.createElement("td");\r
-        td.innerHTML="No device is used in this period";\r
-        tr.appendChild(td);\r
-        tbody.appendChild(tr);\r
-    }\r
-\r
-    table.appendChild(tbody);\r
-    return table;\r
-}\r
-\r
-////////////////////////////\r
-// get the device names in loglist\r
-function getDeviceList(){\r
-\r
-    var nList=loglist["info"].listCount;\r
-    var deviceList = new Array();\r
-    for (var i=0; i<nList; i++){\r
-        logItem=loglist[i];\r
-        if(deviceList.indexOf(logItem.device)==-1){\r
-            deviceList.push(logItem.device);\r
-        }\r
-    }\r
-       return deviceList;\r
-}\r
-\r
-// make canvas to display usage log\r
-function makeCanvas() {\r
-    var canvas = document.getElementById("usagelog");\r
-    if (canvas) {\r
-        var cell = makeCells();\r
-        canvas.appendChild(cell);\r
-        var devicesLegend = makeDevicesLegend();\r
-        canvas.appendChild(devicesLegend);\r
-    }\r
-}\r
-\r
-////////////////////////////\r
-// set up event listner\r
-function addOnLoadEvent(func) {\r
-  if (window.addEventListener) {\r
-    window.addEventListener("load", func, false);\r
-  } else if (window.attachEvent) {  // for IE\r
-    window.attachEvent("onload", func);\r
-  } else  {\r
-    window.onload = func;\r
-  }\r
-}\r
-\r
-////////////////////////////\r
-// initialize\r
-function init(){\r
-\r
-    // get loglist info\r
-    beginTime=new Date(loglist["info"].beginTime.replace(/-/g, "/"));\r
-    endTime=new Date(loglist["info"].endTime.replace(/-/g, "/"));\r
-    // get device names in loglist\r
-    deviceList=getDeviceList();\r
-\r
-       // set up onLoad event listner\r
-       addOnLoadEvent(makeCanvas);\r
-}\r
-\r
-////////////////////////////\r
-// startup from here\r
-init();\r
-\r
index cef5467..241a0f2 100644 (file)
@@ -120,84 +120,6 @@ int queryMacFromMngDb(char* macAddress, char* userId, char* extraId){
   return found;
 }
 
-/******************************************
-put gate-open log to management db 
-******************************************/
-int putOpenToMngDb(char* macAddress){
-
-  char queryStr[BUFFMAXLN];
-  struct utsname uts;
-
-  /* get domain name */
-  uname(&uts);
-
-  /* prepare query string */
-  snprintf(queryStr, BUFFMAXLN, 
-          "insert into sessionmd "
-          "(macAddress, gatewayName, openTime, closeTime) "
-          "values ('%s','%s', now(), 0)",
-          macAddress, uts.nodename);
-
-  /* send SQL query */
-  if (mysql_query(&mysql, queryStr)){
-     err_msg("ERR at %s#%d: mysql query: %s",__FILE__,__LINE__,
-            mysql_error(&mysql));
-     return FALSE;
-  }
-
-  return TRUE;
-}
-
-/******************************************
-put gate-close log to management db
-******************************************/
-int putCloseToMngDb(char* macAddress){
-
-  char queryStr[BUFFMAXLN];
-
-  /* prepare query string */
-  snprintf(queryStr, BUFFMAXLN, 
-          "update sessionmd set closeTime=now() "
-          "where macAddress='%s' and closeTime=0", macAddress);
-
-  /* send SQL query */
-  if (mysql_query(&mysql, queryStr)){
-     err_msg("ERR at %s#%d: mysql query: %s",__FILE__,__LINE__,
-            mysql_error(&mysql));
-     return FALSE;
-  }
-
-  return TRUE;
-
-}
-
-/******************************************
-put MAC-IP pair to management db
-******************************************/
-int putMacIpPairToMngDb(char* macAddress, char* ipAddress){
-
-  char queryStr[BUFFMAXLN];
-  struct utsname uts;
-
-  /* get domain name */
-  uname(&uts);
-
-  /* prepare query string */
-  snprintf(queryStr, BUFFMAXLN, 
-          "insert into macippair "
-          "(macAddress, ipAddress, findTime) "
-          "values ('%s','%s', now())",
-          macAddress, ipAddress);
-
-  /* send SQL query */
-  if (mysql_query(&mysql, queryStr)){
-     err_msg("ERR at %s#%d: mysql query: %s",__FILE__,__LINE__,
-            mysql_error(&mysql));
-     return FALSE;
-  }
-
-  return TRUE;
-}
 
 /*******************************************
  get next mac address from watchlist table in management db
@@ -302,6 +224,7 @@ int QueryMacFromMngDb(char* macAddress, char* userId, char* extraId){
   if(debug>1) err_msg("DEBUG:(%d)<=queryMacFromMngDb(,%s,%s)",ret,userId,extraId);
   return ret;
 }
+
 int InitMngDb(void){
   int ret;
   if(debug>1) err_msg("DEBUG:=>initMngDb()");
@@ -309,37 +232,13 @@ int InitMngDb(void){
   if(debug>1) err_msg("DEBUG:(%d)<=closeMngDb()",ret);
   return ret;
 }
+
 void CloseMngDb(void){
   if(debug>1) err_msg("DEBUG:=>closeMngDb()");
   closeMngDb();
   if(debug>1) err_msg("DEBUG:<=closeMngDb()");
 }
 
-int PutCloseToMngDb(char* macAddress){
-  int ret;
-  if(debug>1) err_msg("DEBUG:=>putCloseToMngDb(%s)", macAddress);
-  ret = putCloseToMngDb(macAddress);
-  if(debug>1) err_msg("DEBUG:(%d)<=putCloseToMngDb()",ret);
-  return ret;
-}
-
-int PutOpenToMngDb(char* macAddress){
-  int ret;
-  if(debug>1) err_msg("DEBUG:=>putOpenToMngDb(%s)", macAddress);
-  ret = putOpenToMngDb(macAddress);
-  if(debug>1) err_msg("DEBUG:(%d)<=putOpenToMngDb()",ret);
-  return ret;
-}
-
-int PutMacIpPairToMngDb(char* macAddress, char* ipAddress){
-  int ret;
-  if(debug>1) err_msg("DEBUG:=>putMacIpPairToMngDb(%s,%s)", 
-                     macAddress, ipAddress);
-  ret = putMacIpPairToMngDb(macAddress, ipAddress);
-  if(debug>1) err_msg("DEBUG:(%d)<=putMacIpPairToMngDb()",ret);
-  return ret;
-}
-
 int GetNextRecordFromWatchlistTableInMngDb(char* macAddress){
   int ret;
   if(debug>1) err_msg("DEBUG:=>getNextRecordFromWatchlisttableInMngDb()");
index 100ed48..25ecfce 100644 (file)
@@ -183,9 +183,11 @@ int  main(int argc, char **argv)
   uselessCheckTime=time(NULL);
   DelUselessSessions();
 
+  DelOldMacInfoInWorkDb(); /**********************************/
   /*** enter infinite loop of packet inspection ***/
   while(1){
 
+    
     /* if sig-hup flag is on, reload this program */
     /* sig-hup flag is set in sigHupHandler, when HUP signal arrives */
     if(sigHupArrived)execlp(argv[0], argv[0], NULL);
@@ -210,10 +212,12 @@ int  main(int argc, char **argv)
     /* if no packet */
     if(ret==0){
  
-      /* when long time passed from previous check, check&delete useless sessions */
+      /* when long time passed from previous check, */
+      /* check&delete useless sessions and old macinfo */
       if( time(NULL) - uselessCheckTime > checkInterval ){
        uselessCheckTime = time(NULL);
        DelUselessSessions();
+       DelOldMacInfoInWorkDb();
       }
 
       /* and return to loop top */
@@ -304,11 +308,11 @@ int  main(int argc, char **argv)
       SetMacIpPair(macAddress, ipAddress, userId, extraId);
     }
 
-    /*  check useless sessions at some interval */
-    /* (MAC and IP pairs are removed in stop session) */
+    /*  check useless sessions and old macinfo at some interval */
     if( time(NULL) - uselessCheckTime > checkInterval ){
       uselessCheckTime = time(NULL);
       DelUselessSessions();
+      DelOldMacInfoInWorkDb();
     }
   }
   /*** end of infinite loop ***/
index 64b7daa..5716d4a 100644 (file)
@@ -173,9 +173,6 @@ int ReFormatMacAddr(char* macAddr);
 int InitMngDb(void);
 int QueryMacFromMngDb(char* macAddress, char* userid, char* extraid);
 void CloseMngDb(void);
-int PutCloseToMngDb(char* macAddress);
-int PutOpenToMngDb(char* macAddress);
-int PutMacIpPairToMngDb(char* macAddress, char* ipAddress);
 int GetNextRecordFromWatchlistTableInMngDb(char* macAddress);
 int IsAllFoundInWatchlistTable(void);
 
@@ -197,6 +194,7 @@ int IsActiveRuleInWorkDb(int ruleNumber);
 int IsFoundMacIpPairInWorkDb(char* macAddress, char* ipAddress);
 int PutMacIpPairToWorkDb(char* macAddress, char* ipAddress);
 int DelMacIpPairsInWorkDb(char* macAddress);
+int DelOldMacInfoInWorkDb(void);
 
 /* session.c */
 int AddSession(char* macAddress, char* userId, char* extraId);
index 151f6d2..b743f5d 100644 (file)
@@ -87,8 +87,6 @@ int addSession(char* macAddress, char* userId, char* extraId){
   /* write open log to syslog */
   WriteOpenToSyslog(userId, extraId, macAddress);
 
-  /* write log to management db */
-  PutOpenToMngDb(macAddress);
   return TRUE;
 }
 
@@ -122,9 +120,6 @@ void delSession(char* macAddress){
   if(debug>0) WriteSessionInfoToSyslog(userId, extraId, 
                                       macAddress, ruleNumber);
 
-  /* write close log to management db */
-  PutCloseToMngDb(macAddress);
-
   /* reset the memory of MAC IP pair */
   ResetMacIpPairs(macAddress);
 }
@@ -180,9 +175,6 @@ int closeSession(void* pParam, int argc, char *argv[], char* colName[]){
   WriteCloseToSyslog(userId, extraId,  macAddress, openTime);
   if(debug>0) WriteSessionInfoToSyslog(userId, extraId, macAddress, ruleNumber);
 
-  /* write close log to management db */
-  PutCloseToMngDb(macAddress);
-
   /* reset the memory of MAC IP pair */
   ResetMacIpPairs(macAddress);
 
@@ -338,7 +330,6 @@ void removeSessionUnmatchedToIpfwRule(DB* ruleTable, DB* sessionTable){
        err_msg("ERR at %s#%d: fail to get session info",__FILE__,__LINE__);
       }else{
        WriteCloseToSyslog(userId, extraId, macAddress, openTime);
-       PutCloseToMngDb(macAddress);
        DelSessionFromWorkDb(macAddress);
       }
 
@@ -396,7 +387,6 @@ void  removeIpfwRuleUnmatchedToSession(DB* ruleTable, DB* sessionTable){
 
       /* write log */
       WriteCloseToSyslog("?", "", macAddress, time(NULL));
-      PutCloseToMngDb(macAddress);
       
       /* write session info to syslog (no user info)*/
       if(debug>0) WriteSessionInfoToSyslog("?","", macAddress, ruleNumber);
@@ -480,10 +470,6 @@ void setMacIpPair(char* macAddress, char* ipAddress, char* userId, char* extraId
   if(!IsFoundMacIpPairInWorkDb(macAddress, ipAddress)){
     PutMacIpPairToWorkDb(macAddress, ipAddress);
 
-    /* record the pair to management db */
-    /* the pair in management db is the sccess log (don't remove at the end of session)*/
-    PutMacIpPairToMngDb(macAddress, ipAddress);
-
     /* write to syslog */
     if(isNull(extraId)){
       err_msg("FIND: user %s from %s at %s", userId, ipAddress, macAddress);
index 31d1a8b..775aa71 100644 (file)
@@ -553,6 +553,26 @@ int delMacIpPairsInWorkDb(char* macAddress){
 
 }
 
+/********************************************
+Delete old mac info in work db
+ (detected before 1 month)
+********************************************/
+int delOldMacInfoInWorkDb(void){
+  char *pErrMsg=NULL;
+
+  /* SQL DELETE COMMAND */
+  char *deleteCmd="DELETE FROM macinfo WHERE detectTime<strftime('%s','now','-1 month')";
+  int resultFlag=TRUE;
+
+  /* execute delete */
+  if(sqlite3_exec(dbMd, deleteCmd, NULL, NULL, &pErrMsg)!=SQLITE_OK){
+    resultFlag=FALSE;
+    err_msg("ERR at %s#%d: sqlite3_exec: %s",__FILE__,__LINE__,pErrMsg);
+  }
+
+  return resultFlag;
+}
+
 /*********************************************************
  routines for debugging output
 *********************************************************/
@@ -685,3 +705,11 @@ int DelMacIpPairsInWorkDb(char* macAddress){
   if(debug>1) err_msg("DEBUG:(%d)<=delMacIpPairsInWorkDb( )", ret);
   return ret;
 }
+
+int DelOldMacInfoInWorkDb(void){
+  int ret;
+  if(debug>1) err_msg("DEBUG:=>delOldMacInfoInWorkDb()");
+  ret=delOldMacInfoInWorkDb();
+  if(debug>1) err_msg("DEBUG:(%d)<=delOldMacInfoInWorkDb()", ret);
+  return ret;
+}
index 1bc3034..9645188 100644 (file)
@@ -579,10 +579,19 @@ int putRegisterPageToClient(char *language, char* macAddress, char* deviceName,
   char* regCgi="";
   char* regDoc="";
   char* maxDevicesStr;
+  char* listDisplayStyle;
+  
 
   /* get Maximum count of devices for an user from conf file */
   maxDevicesStr=GetConfValue("MaxDevices");
 
+  /* if exist already regsitered device, show the device list in page */
+  if(CountMacAddrsForUserInMngDb(userId,extraId)>0){
+    listDisplayStyle="display:block";
+  }else{
+    listDisplayStyle="display:none";
+  }
+  
   /* setup cgi and doc */
   if(ownReg){
     regCgi=GetConfValue("OwnCgi");
@@ -629,6 +638,7 @@ int putRegisterPageToClient(char *language, char* macAddress, char* deviceName,
     HtmlReplace(buff, "%%USERID%%", userId);
     HtmlReplace(buff, "%%REDIRECTEDURL%%", redirectedUrl);
     HtmlReplace(buff, "%%MAXDEVICES%%", maxDevicesStr);
+    HtmlReplace(buff, "%%LISTDISPLAYSTYLE%%", listDisplayStyle);
 
     if(strstr(buff, "%%MACREGLIST%%")!=NULL){
       PutMacRegListToClient(userId, extraId);
@@ -1161,9 +1171,6 @@ int putUpdatePageToClient(char *language, char* userId, char* extraId, int ownUp
     if(strstr(buff, "%%MACLIST%%")!=NULL){
       PutMacListToClient(userId,extraId);
     }
-    else if(strstr(buff, "%%USAGELOG%%")!=NULL){
-      PutUsageLogToClient(userId, extraId, language);
-    }
     else if(strstr(buff, "%%ERRORLIST%%")!=NULL){
       InsertMessageToPage(language);
     }
@@ -1234,54 +1241,6 @@ void putMacListToClient(char* userId, char* extraId){
   }
 }
 
-/*********************************************/
-/* put usage log to the client            */
-/*********************************************/
-void putUsageLogToClient(char *userId, char* extraId, char* language){
-
-  char macAddr[ADDRMAXLN]="";
-  char deviceName[WORDMAXLN]="";
-  char openTime[WORDMAXLN]="";
-  char closeTime[WORDMAXLN]="";
-  char gatewayName[WORDMAXLN]="";
-  char beginTime[WORDMAXLN]="";
-  char endTime[WORDMAXLN]="";
-  int dateCount=0;
-  char* p;
-  int count=0;
-
-  /*** get usage log and insert it to html doc as JSON format */
-  /* get one log form management db */
-  while(GetNextUsageLogFromMngDb(userId,extraId,macAddr,deviceName,
-                                openTime,closeTime,gatewayName)){
-
-    /* split hostname only (opengate01.example.com -> opengate01) */
-    if((p=strchr(gatewayName,'.'))!=NULL) *p='\0';
-
-    /* put out the log as a JSON item */
-    /* table skeleton is prepared in template file */
-    printf("\t %d:{\n", count);
-    printf("\t\t macAddress: '%s',\n", macAddr);
-    printf("\t\t device: '%s',\n",deviceName);
-    printf("\t\t openTime: '%s',\n",openTime);
-    printf("\t\t closeTime: '%s',\n",closeTime);
-    printf("\t\t gateway: '%s'\n",gatewayName);
-    printf("\t },\n");
-
-    /* increment log counter */
-    count++;
-  }
-
-  /* put out the JSON item for summary info of the list */
-  GetTimeRangeToShowLog(beginTime, endTime, &dateCount);
-  printf("\t info:{\n");
-  printf("\t\t beginTime: '%s',\n", beginTime);
-  printf("\t\t endTime: '%s',\n", endTime);
-  printf("\t\t listCount: %d,\n", count);
-  printf("\t\t dateCount: %d\n", dateCount);
-  printf("\t }\n");
-}
-
 /********************************************************/
 /* the client is an allowable http-user-agent or not    */
 /* the allowable http-user-agent can be defined in conf */
@@ -1520,12 +1479,6 @@ void PutMacListToClient(char *userId, char* extraId){
   if(debug>1) err_msg("DEBUG:<=putMacListToClient( )");
 }
 
-void PutUsageLogToClient(char *userId, char* extraId, char* language){
-  if(debug>1) err_msg("DEBUG:=>putUsageLogToClient(%s,%s,%s)",userId,extraId,language);
-  putUsageLogToClient(userId,extraId,language);
-  if(debug>1) err_msg("DEBUG:<=putUsageLogToClient( )");
-}
-
 int IsAccessedFromAllowableAgent(void){
   int ret;
   if(debug>1) err_msg("DEBUG:=>isAccessedFromAllowableAgent( )");
index 7b768cb..744e1c3 100644 (file)
@@ -317,7 +317,8 @@ int getNextMacAddrFromMngDb(char* userId, char* extraId, char* macAddress, char*
 int putMacModifyLogToMngDb(char* userId, char* extraId, char* macAddr, char modifyType){
 
   char queryStr[BUFFMAXLN];
+
+  /*** insert modify log ***/
   /* prepare query string */
   snprintf(queryStr, BUFFMAXLN, 
           "insert into macmodify "
@@ -331,6 +332,18 @@ int putMacModifyLogToMngDb(char* userId, char* extraId, char* macAddr, char modi
             mysql_error(&mysql));
      return FALSE;
   }
+  /*** remove old log ***/ 
+  /* prepare query string */
+  snprintf(queryStr, BUFFMAXLN, 
+          "delete from macmodify "
+          " where modifyDate < adddate(now(), interval -1 day) ");
+
+  /* send SQL query */
+  if (mysql_query(&mysql, queryStr)){
+     err_msg("ERR at %s#%d: mysql query: %s",__FILE__,__LINE__,
+            mysql_error(&mysql));
+     return FALSE;
+  }
 
   return TRUE;
 }
@@ -392,35 +405,18 @@ int countMacModifyPerDayInMngDb(char* userId, char* extraId, char* macAddress){
 
 /*********************************************************/
 /* delete a mac address registered in the management db  */
-/* in actuality, not delete row, but set the status="D"  */
-/*  when usage log for the address is found in log table */
+/* actuality, not delete row, but set the status="D"     */
 /* macAddr:(input)                                       */
 /*********************************************************/
 int delMacAddrFromMngDb(char* macAddr){
 
   char queryStr[BUFFMAXLN];
 
-  /* if the mac is found in the past session log,        */
-  /* the owner info is needed for the log inspection     */
-  /* thus the info is not deleted, but set as status="D" */
-  if(IsSessionFoundInMngDb(macAddr)){
-
     /* prepare query string */
     /* don't touch device of status="I"(set Inactive by admin) */
     snprintf(queryStr, BUFFMAXLN, 
             "update macaddrs set status='D',limitDate=now() "
             " where macAddress='%s' and (status='A' or status='P')", macAddr);
-  }
-
-  /* if mac is not found in past session log, the row is removed */
-  else{
-
-    /* prepare query string */
-    /* don't touch device of status="I"(set Inactive by admin) */
-    snprintf(queryStr, BUFFMAXLN, 
-            "delete from macaddrs "
-            " where macAddress='%s' and (status='A' or status='P')", macAddr);
-  }
 
   /* send SQL query */
   if (mysql_query(&mysql, queryStr)){
@@ -483,107 +479,6 @@ int pauseMacAddrInMngDb(char* macAddr){
   return TRUE;
 }
 
-/******************************************
- is the mac address used in session log
-******************************************/
-int isSessionFoundInMngDb(char* macAddr){
-
-  MYSQL_RES *res=NULL;
-  MYSQL_ROW row;
-  char queryStr[BUFFMAXLN];
-  int ret;
-
-  /* prepare query string */
-  /* get row for addr.entry<session.open<addr.limit */
-  snprintf(queryStr, BUFFMAXLN, 
-          "select * from macaddrs, sessionmd "
-          " where macaddrs.macAddress=sessionmd.macAddress and "
-          " macaddrs.macAddress='%s' and "
-          " entryDate<openTime and openTime<limitDate",
-          macAddr);
-  
-  /* send SQL query */
-  if (mysql_query(&mysql, queryStr)){
-    err_msg("ERR at %s#%d: mysql query: %s",__FILE__,__LINE__,
-           mysql_error(&mysql));
-    return FALSE;
-  }
-  
-  /* store result */
-  res = mysql_store_result(&mysql);
-
-  /* output table name */
-  row = mysql_fetch_row(res);
-  
-  /* if found, return true */
-  if(row!=NULL) ret=TRUE;
-
-  /* if not found, return false */
-  else ret=FALSE;
-
-  mysql_free_result(res);
-  return ret;
-}
-
-/*******************************************
- get next next usage log from management db
- if end of list, return false
-*******************************************/
-int getNextUsageLogFromMngDb(char* userId, char* extraId, char* macAddr, char* deviceName, char* openTime, char* closeTime, char* gatewayName){
-  static MYSQL_RES *res=NULL;
-  MYSQL_ROW row;
-  char queryStr[BUFFMAXLN];
-
-  /* set default values */
-  macAddr[0]=deviceName[0]=openTime[0]=gatewayName[0]='\0';
-
-  /* if do not get result yet */
-  if(res==NULL){
-
-    /* prepare query string */
-    /* get log where addr.entry < session.open < addr.limit */
-    /*  (the same device may be registered by other users in old days) */
-    snprintf(queryStr, BUFFMAXLN, 
-            "select macaddrs.macAddress, device, openTime, closeTime, "
-            " gatewayName "
-            " from macaddrs, sessionmd "
-            " where macaddrs.macAddress=sessionmd.macAddress "
-            " and entryDate < openTime and openTime < limitDate "
-            " and (%s<closeTime or closeTime=0) "
-            " and userId='%s' and extraId='%s'",
-            GetConfValue("ShowLogAfter"), userId, extraId);
-
-    /* send SQL query */
-    if (mysql_query(&mysql, queryStr)){
-      err_msg("ERR at %s#%d: mysql query: %s",__FILE__,__LINE__,
-             mysql_error(&mysql));
-      return FALSE;
-    }
-    
-    /* store result */
-    res = mysql_store_result(&mysql);
-  }
-
-  /* output table name */
-  row = mysql_fetch_row(res);
-
-  /* if found, return values */
-  if(row!=NULL){
-    strlcpy(macAddr, row[0],ADDRMAXLN);
-    strlcpy(deviceName,row[1],WORDMAXLN);
-    strlcpy(openTime,row[2],WORDMAXLN);
-    strlcpy(closeTime,row[3],WORDMAXLN);
-    strlcpy(gatewayName,row[4],WORDMAXLN);
-    return TRUE;
-  }
-  /* if not found, free memory area */
-  else{
-    mysql_free_result(res);
-    return FALSE;
-  }
-}
-
-
 /*******************************************
  get next mail address near limit date
 from management db 
@@ -965,25 +860,6 @@ int PauseMacAddrInMngDb(char* macAddr){
   return ret;
 }
 
-int IsSessionFoundInMngDb(char* macAddr){
-  int ret;
-  if(debug>1) err_msg("DEBUG:=>isSessionFoundInMngDb(%s)",macAddr);
-  ret=isSessionFoundInMngDb(macAddr);
-  if(debug>1) err_msg("DEBUG:(%d)<=isSessionFoundInMngDb( )",ret);
-  return ret;
-}
-
-int GetNextUsageLogFromMngDb(char* userId, char* extraId, char* macAddr, 
- char* deviceName, char* openTime, char* closeTime, char* gatewayName){
-  int ret;
-  if(debug>1) err_msg("DEBUG:=>getNextUsageLogFromMngDb(%s,%s)",userId,extraId);
-  ret=getNextUsageLogFromMngDb(userId,extraId,macAddr,deviceName,
-                             openTime,closeTime,gatewayName);
-  if(debug>1) err_msg("DEBUG:(%d)<=getNextUsageLogFromMngDb(,,%s,%s,%s,%s,%s)",
-                ret,macAddr,deviceName,openTime,closeTime,gatewayName);
-  return ret;
-}
-
 int GetNextMailAddressFromMngDb(char* mailAddress, char* limitDate, char*device){
   int ret;
   if(debug>1) err_msg("DEBUG:=>getnextMailAddressFromMngDb( )");
index 1cbbfe5..7c0ab56 100644 (file)
@@ -189,8 +189,6 @@ int CountMacModifyPerDayInMngDb(char* userId, char* extraId, char* macAddress);
 int DelMacAddrFromMngDb(char* macAddr);
 int RenewMacAddrInMngDb(char* macAddr);
 int PauseMacAddrInMngDb(char* macAddr);
-int IsSessionFoundInMngDb(char* macAddr);
-int GetNextUsageLogFromMngDb(char* userId, char* extraId, char* macAddr, char* deviceName, char* openTime, char* closeTime, char* gatewayName);
 int GetNextMailAddressFromMngDb(char* mailAddress, char* limitDate, char*device);
 int GetTimeRangeToShowLog(char* beginTime, char* endTime, int* dateCount);
 int RenameDeviceNameInMngDb(char* macAddr, char* nameStr);
@@ -246,7 +244,6 @@ int IsCorrectCookie(char* cookie, int userType);
 int AnalyzeUpdateRequestAndExecute(char *content, char* userId, char* extraId);
 int PutUpdatePageToClient(char *language, char* userId, char* extraId, int ownUpdate, char* redirectedUrl);
 void PutMacListToClient(char *userId, char* extraId);
-void PutUsageLogToClient(char *userId, char* extraId, char* language);
 int IsAccessedFromAllowableAgent(void);
 
 /* messages.c */
index fb62ae2..785935d 100755 (executable)
@@ -38,12 +38,6 @@ if(!(list($device, $mailAddress)=getDataFromMysql($macAddress))){
        return;
 }
 
-// if reported recently, skip reporting
-if(skipReporting($link, $macAddress, $gatewayName, $reportInterval)){
-       mysqli_close($link);
-       return;
-}
-
 // close database
 mysqli_close($link);
 
@@ -131,37 +125,6 @@ function getDataFromMysql($macAddress){
 }
 
 /***
-To avoid to send too many mails, 
- skip if there are recent logs having same macaddress and same gateway. 
-If you want to change the report period, $reportPeriod is defined at the top of this file.
-***/
-function skipReporting($link, $macAddress, $gatewayName, $reportInterval){
-       
-       // query
-       $result = mysqli_query($link, 'SELECT count(*) FROM sessionmd '
-               .'WHERE EXISTS (SELECT * FROM sessionmd '
-               .'WHERE macAddress="'.$macAddress.'" '
-               .'AND gatewayName LIKE "'.$gatewayName.'.%" '
-               .'AND openTime > NOW() - INTERVAL '.$reportInterval.' '
-               .'AND openTime < NOW() - INTERVAL 1 MINUTE '
-               .')'
-               );
-
-       if (!$result){
-               syslog(LOG_INFO, 'ERR: Fail query '.mysqli_error());
-               return TRUE;
-       }
-
-       // get data
-       if($row = mysqli_fetch_row($result)) $count = $row[0];
-       else    $count = 0;
-
-       // if recent logs exist, skip is true
-       if($count>0)return TRUE;
-       else return FALSE;
-}
-
-/***
 send mail to the user mail address
 ***/
 function sendMailToUser($mailSender, $mailAddress, $device, $gatewayName, 
diff --git a/phpsrc/showlog.php b/phpsrc/showlog.php
deleted file mode 100644 (file)
index a151a2a..0000000
+++ /dev/null
@@ -1,79 +0,0 @@
-<html>
-<head>
-<title></title>
-</head>
-<body>
-
-<h2>Show Log</h2>
-
-<?php
-  /************************************************************/
-  // show the opengatem usage log in the web page.
-  // the query condition is acquired from the html input from.
-  // default is as follows: any user, any device, last 3 days 
-  // database connecttion parameters might be modified.
-  // As this script should be used only by the administrators, 
-  // it should be protected by some access control method.
-  /************************************************************/
-
-  // set default values
-  $userId=$device='%';
-  $now=date('Y-m-d H:i:s');
-  $fromTime=date('Y-m-d H:i:s', strtotime($now." -3 day"));
-  $toTime=$now;
-
-  // get request data
-  if(isset($_GET['userId']))$userId=$_GET['userId'];
-  if(isset($_GET['device']))$device=$_GET['device'];
-  if(isset($_GET['fromTime']))$fromTime=$_GET['fromTime'];
-  if(isset($_GET['toTime']))$toTime=$_GET['toTime'];
-
-  // show html table for query parameters
-  print("<p><table>");
-  print("<form method=GET action=showlog.php");
-  print("<tr><td>UserId</td><td><input size=30 type=text name=userId value='".$userId."'></td></tr>");
-  print("<tr><td>Device</td><td><input size=30 type=text name=device value='".$device."'></td></tr>");
-  print("<tr><td>FromTime</td><td><input size=30 type=text name=fromTime value='".$fromTime."'></td></tr>");
-  print("<tr><td>ToTime</td><td><input size=30 type=text name=toTime value='".$toTime."'></td></tr>");
-  print("<tr><td></td><td><input type=submit value='send'></td></tr>");
-  print("</table></p>");
-
-  // connect and access to MySql db
-  $link = mysqli_connect('localhost', 'root', '');
-  if (!$link) die('Cannot connet to DB'.mysqli_error());
-
-  $db_selected = mysqli_select_db($link, 'opengatem');
-  if (!$db_selected) die('Cannot select DB'.mysqli_error());
-
-  mysqli_set_charset($link, 'utf8');
-
-  $result = mysqli_query($link, 'SELECT * FROM sessionview where userId like "'.$userId.'" and device like "'.$device.'" and "'.$fromTime.'"<openTime and openTime<"'.$toTime.'"');
-
-  if (!$result) die('Fail query'.mysqli_error());
-
-  // show header line
-  print("<table border=1>");
-  print('<tr>');
-  $count=0;
-  while ($field = mysqli_fetch_field($result)) {
-    print('<td>'.$field->name.'</td>');
-    $count++;
-  }
-  print('</tr>');
-
-  // show rows
-  while ($row = mysqli_fetch_row($result)) {
-    print('<tr>');
-    for($i=0; $i<$count; $i++){
-      print('<td>'.$row[$i].'</td>');
-    }
-    print('</tr>');
-  }
-
-  print("</table>");
-  $close_flag = mysqli_close($link);
-
-?>
-
-</body>
-</html>
index 4dd3d9c..65388bd 100644 (file)
@@ -7,8 +7,6 @@
 <h2>Show Tables</h2>
 <p>
 <a href='showtable.php?table=macaddrs'>macaddrs</a> 
-<a href='showtable.php?table=sessionmd'>sessionmd</a> 
-<a href='showtable.php?table=sessionview'>sessionview</a> 
 <a href='showtable.php?table=nicvendors'>nicvendors</a> <br>
 (Show max 1000 rows of selected table).
 </p>
index 59e30a7..37251ad 100644 (file)
@@ -15,17 +15,6 @@ create table if not exists macaddrs(
        renewDate DATETIME,
        limitDate DATETIME);
 
-create table if not exists sessionmd(
-       macAddress CHAR(18),
-       gatewayName TINYTEXT,
-       openTime DATETIME,
-       closeTime DATETIME);
-
-create table if not exists macippair(
-       macAddress CHAR(18),
-       ipAddress TINYTEXT,
-       findTime DATETIME);
-
 create table if not exists macmodify(
        userId TINYTEXT,
        extraId TINYTEXT,
@@ -42,15 +31,3 @@ create table if not exists watchlist(
        reporting CHAR(1),
        memo TINYTEXT);
 
-create or replace view sessionview as select
-       userId,
-       extraId,
-       macaddrs.macAddress,
-       device,
-       openTime,
-       closeTime,
-       gatewayName 
-       from macaddrs,sessionmd 
-       where macaddrs.macAddress=sessionmd.macAddress 
-       and entryDate<openTime and openTime<limitDate;
-
diff --git a/sqlscript/updatescript4 b/sqlscript/updatescript4
deleted file mode 100644 (file)
index de717ff..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-/*
-Remove the log record passing 1 year after recorded date.
-Use as
- mysql < updatescript4
-*/
-use opengatem;
-delete from sessionmd where closeTime<adddate(now(), interval -1 year);
-delete from macippair where findTime<adddate(now(), interval -1 year);
-
-