<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>
-->
</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>
<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>
<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'>
%%MACREGLIST%%
</table>
</p>
+</div>
<p>
<a href=opengatemup.cgi?lang=en>Update Page</a>
<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>
%%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>
<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>
<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'>
%%MACREGLIST%%
</table>
</p>
-
+</div>
<p>
<a href=opengatemup.cgi?lang=ja>登録更新ページ</a>
<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";
%%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>
+++ /dev/null
-// 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
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
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()");
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()");
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);
/* 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 */
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 ***/
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);
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);
/* write open log to syslog */
WriteOpenToSyslog(userId, extraId, macAddress);
- /* write log to management db */
- PutOpenToMngDb(macAddress);
return TRUE;
}
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);
}
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);
err_msg("ERR at %s#%d: fail to get session info",__FILE__,__LINE__);
}else{
WriteCloseToSyslog(userId, extraId, macAddress, openTime);
- PutCloseToMngDb(macAddress);
DelSessionFromWorkDb(macAddress);
}
/* write log */
WriteCloseToSyslog("?", "", macAddress, time(NULL));
- PutCloseToMngDb(macAddress);
/* write session info to syslog (no user info)*/
if(debug>0) WriteSessionInfoToSyslog("?","", macAddress, ruleNumber);
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);
}
+/********************************************
+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
*********************************************************/
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;
+}
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");
HtmlReplace(buff, "%%USERID%%", userId);
HtmlReplace(buff, "%%REDIRECTEDURL%%", redirectedUrl);
HtmlReplace(buff, "%%MAXDEVICES%%", maxDevicesStr);
+ HtmlReplace(buff, "%%LISTDISPLAYSTYLE%%", listDisplayStyle);
if(strstr(buff, "%%MACREGLIST%%")!=NULL){
PutMacRegListToClient(userId, extraId);
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);
}
}
}
-/*********************************************/
-/* 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 */
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( )");
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 "
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;
}
/*********************************************************/
/* 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)){
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
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( )");
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);
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 */
return;
}
-// if reported recently, skip reporting
-if(skipReporting($link, $macAddress, $gatewayName, $reportInterval)){
- mysqli_close($link);
- return;
-}
-
// close database
mysqli_close($link);
}
/***
-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,
+++ /dev/null
-<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>
<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>
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,
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;
-
+++ /dev/null
-/*
-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);
-
-