• R/O
  • HTTP
  • SSH
  • HTTPS

ds-zither: コミット

this program is deadline monitor for the domain and ssl.

ds-zitherはドメインとSSL証明書の期限監視を中心に、2014年2月から0ベースで開発を開始しました。


コミットメタ情報

リビジョン34997bdb9c23ab0028ee411c4b55961300dbd67b (tree)
日時2014-03-01 22:16:00
作者masashi <masashi@ms-n...>
コミッターmasashi

ログメッセージ

user auth modifide 20140301

変更サマリ

差分

--- /dev/null
+++ b/database/postgres/grant_user.sql
@@ -0,0 +1,9 @@
1+grant ALL on monitor_plan_table TO daemon ;
2+grant ALL on monitor_plan_table_mpukey_in_seq TO daemon ;
3+grant ALL on monitor_server_info_table TO daemon ;
4+grant ALL on monitor_server_info_table_serverkey_in_seq TO daemon ;
5+grant ALL on monitoring_table TO daemon ;
6+grant ALL on monitoring_table_mukey_in_seq TO daemon ;
7+grant ALL on user_auth_table TO daemon ;
8+grant ALL on user_auth_table_uukey_in_seq TO daemon ;
9+
--- a/database/postgres/monitor_plan_table.sql
+++ b/database/postgres/monitor_plan_table.sql
@@ -11,7 +11,7 @@ CREATE TABLE monitor_plan_table (
1111 sosstat_in int,
1212 starttime_lin bigint,
1313 stoptime_lin bigint,
14- modhost_ch1024 char[1024],
14+ modhost_ch1024 varchar(1024),
1515 mpukey_in serial
1616 );
1717
--- a/database/postgres/monitor_server_info_table.sql
+++ b/database/postgres/monitor_server_info_table.sql
@@ -3,7 +3,7 @@ CREATE TABLE monitor_server_info_table (
33 serverip_inet inet not null,
44 spnum_in int not null,
55 serverstat_in int not null,
6- serverinfo_tx text,
6+ serverinfo_ch1024 varchar(1024),
77 serverkey_in serial
88 );
99
@@ -11,7 +11,7 @@ COMMENT ON TABLE monitor_server_info_table IS 'monitoring server information.';
1111 COMMENT ON COLUMN monitor_server_info_table.serverip_inet IS 'server ip adress.';
1212 COMMENT ON COLUMN monitor_server_info_table.spnum_in IS 'server port number.';
1313 COMMENT ON COLUMN monitor_server_info_table.serverstat_in IS 'server status.';
14-COMMENT ON COLUMN monitor_server_info_table.serverinfo_tx IS 'server information.';
14+COMMENT ON COLUMN monitor_server_info_table.serverinfo_ch1024 IS 'server information.';
1515 COMMENT ON COLUMN monitor_server_info_table.serverkey_in IS 'monitoring server ID.';
1616
1717
--- a/database/postgres/monitoring_table.sql
+++ b/database/postgres/monitoring_table.sql
@@ -12,9 +12,9 @@ CREATE TABLE monitoring_table (
1212 premsps_in int,
1313 moextime_lin bigint,
1414 expitime_lin bigint,
15- modhost_ch1024 char[1024],
16- moptions_ch256 char[256],
17- moinfo_ch1024 char[1024],
15+ modhost_ch1024 varchar(1024),
16+ moptions_ch1024 varchar(1024),
17+ moinfo_ch1024 varchar(1024),
1818 mukey_in serial
1919 );
2020
@@ -32,7 +32,7 @@ COMMENT ON COLUMN monitoring_table.premsps_in IS 'Monitoring the status of the p
3232 COMMENT ON COLUMN monitoring_table.moextime_lin IS 'monitor excution time.';
3333 COMMENT ON COLUMN monitoring_table.expitime_lin IS 'expiration date.';
3434 COMMENT ON COLUMN monitoring_table.modhost_ch1024 IS 'monitoring destination host.';
35-COMMENT ON COLUMN monitoring_table.moptions_ch256 IS 'monitoring options.';
35+COMMENT ON COLUMN monitoring_table.moptions_ch1024 IS 'monitoring options.';
3636 COMMENT ON COLUMN monitoring_table.moinfo_ch1024 IS 'monitoring infomations.';
3737 COMMENT ON COLUMN monitoring_table.mukey_in IS 'monitor unique key.';
3838
--- a/database/postgres/user_auth_table.sql
+++ b/database/postgres/user_auth_table.sql
@@ -4,16 +4,18 @@ CREATE TABLE user_auth_table (
44 cnum_in int not null,
55 eoa1_in int not null,
66 eoa2_in int not null,
7+ loginstat_in int,
78 soip_inet inet,
89 starttime_lin bigint,
910 stoptime_lin bigint,
1011 lltime_lin bigint,
12+ lotime_lin bigint,
1113 detime_lin bigint,
12- fmaddr_ch256 char[256] not null,
13- uname_ch128 char[128] not null,
14- pass_ch256 char[256] not null,
15- sesid_ch256 char[256],
16- makeys_ch256 char[256],
14+ fmaddr_ch256 varchar(256) not null,
15+ uname_ch256 varchar(256) not null,
16+ pass_ch256 varchar(256) not null,
17+ sesid_ch256 varchar(256),
18+ makeys_ch256 varchar(256),
1719 uukey_in serial
1820 );
1921
@@ -22,13 +24,15 @@ COMMENT ON COLUMN user_auth_table.aastat_in IS 'accunt authentication status.';
2224 COMMENT ON COLUMN user_auth_table.cnum_in IS 'class number.';
2325 COMMENT ON COLUMN user_auth_table.eoa1_in IS 'element of the associative(1).';
2426 COMMENT ON COLUMN user_auth_table.eoa2_in IS 'element of the associative(2).';
27+COMMENT ON COLUMN user_auth_table.loginstat_in IS 'Login status.';
2528 COMMENT ON COLUMN user_auth_table.soip_inet IS 'source ip address.';
2629 COMMENT ON COLUMN user_auth_table.starttime_lin IS 'services start time.';
2730 COMMENT ON COLUMN user_auth_table.stoptime_lin IS 'services stop time.';
2831 COMMENT ON COLUMN user_auth_table.lltime_lin IS 'last login time.';
32+COMMENT ON COLUMN user_auth_table.lotime_lin IS 'last logout time.';
2933 COMMENT ON COLUMN user_auth_table.detime_lin IS 'deadline time.';
3034 COMMENT ON COLUMN user_auth_table.fmaddr_ch256 IS 'first mail address.';
31-COMMENT ON COLUMN user_auth_table.uname_ch128 IS 'user name.';
35+COMMENT ON COLUMN user_auth_table.uname_ch256 IS 'user name.';
3236 COMMENT ON COLUMN user_auth_table.pass_ch256 IS 'password.';
3337 COMMENT ON COLUMN user_auth_table.sesid_ch256 IS 'session id.';
3438 COMMENT ON COLUMN user_auth_table.makeys_ch256 IS 'mail authentication key.';
--- a/ds-apollon/include/php/db.inc
+++ b/ds-apollon/include/php/db.inc
@@ -3,7 +3,7 @@
33
44 function db_connect()
55 {
6-require("../config.inc");
6+require("include/config.inc");
77
88 if(0 == strcmp($__database, "POSTGRES")){
99 $conn = Pg_connect($__pgsql_data);
@@ -24,7 +24,7 @@ return $conn;
2424
2525 function db_querym($conn, $sql)
2626 {
27-require("../config.inc");
27+require("include/config.inc");
2828
2929 if(0 == strcmp($__database, "POSTGRES")){
3030 $result = pg_query($conn, $sql);
@@ -42,7 +42,7 @@ return $result;
4242
4343 function db_query($conn, $sql)
4444 {
45-require("../config.inc");
45+require("include/config.inc");
4646
4747 $htco = $_SERVER["HTTP_COOKIE"];
4848 $htac = $_SERVER['HTTP_ACCEPT'];
@@ -78,9 +78,8 @@ if(($fp = fopen($logfile, "a+"))==NULL){
7878 }
7979
8080 $alldata = $udate . "\t" . $htco . "\t" . $htac . "\t" . $htcon . "\t" . $htho . "\t" . $read . "\t" . $reho . "\t" . $htre . "\t" . $qust . "\t" . $htus . "\t" . $sql . "\n";
81- fwrite($fp, $alldata);
82- fclose($fp);
83- }
81+fwrite($fp, $alldata);
82+fclose($fp);
8483
8584 if(0 == strcmp($__database, "POSTGRES")){
8685 $result = pg_query($conn, $sql);
@@ -92,6 +91,7 @@ else if(0 == strcmp($__database, "MYSQL")){
9291 }
9392 else{
9493 }
94+
9595 return $result;
9696 }
9797
@@ -100,7 +100,7 @@ return $result;
100100
101101 function db_num_rows($result)
102102 {
103-require("../config.inc");
103+require("include/config.inc");
104104
105105 if(0 == strcmp($__database, "POSTGRES")){
106106 $num = pg_num_rows($result);
@@ -119,7 +119,7 @@ return 0;
119119
120120 function db_fetch_Result($result, $row, $field)
121121 {
122-require("../config.inc");
122+require("include/config.inc");
123123
124124 if(0 == strcmp($__database, "POSTGRES")){
125125 $reso = pg_fetch_Result($result, $row, $field);
@@ -142,7 +142,7 @@ else if(0 == strcmp($__database, "MYSQL")){
142142
143143 function db_free_result($result)
144144 {
145-require("../config.inc");
145+require("include/config.inc");
146146
147147 if(0 == strcmp($__database, "POSTGRES")){
148148 pg_free_result($result);
@@ -159,7 +159,7 @@ else if(0 == strcmp($__database, "MYSQL")){
159159
160160 function db_Close($conn)
161161 {
162-require("../config.inc");
162+require("include/config.inc");
163163
164164 if(0 == strcmp($__database, "POSTGRES")){
165165 pg_Close($conn);
@@ -173,10 +173,4 @@ else if(0 == strcmp($__database, "MYSQL")){
173173 }
174174
175175
176-
177-
178176 ?>
179-
180-
181-
182-
--- a/ds-apollon/include/php/session_start.inc
+++ b/ds-apollon/include/php/session_start.inc
@@ -1,5 +1,4 @@
11 <?php
2-
32 session_start();
43
54 if(empty($_SESSION['count'])) {
@@ -24,4 +23,3 @@ else{
2423 }
2524
2625 ?>
27-
--- /dev/null
+++ b/ds-apollon/include/php/user_auth_db.inc
@@ -0,0 +1,63 @@
1+<?php
2+
3+function user_auth_db($login_user, $login_pass)
4+{
5+
6+$conn = db_connect();
7+if(!$conn){
8+ return -1;
9+ }
10+
11+$result = db_query($conn, "select * from user_auth_table where uname_ch256='$login_user' and pass_ch256='$login_pass';");
12+if(!$result){
13+ return -2;
14+ }
15+$num = db_num_rows($result);
16+if($num == 1){
17+ $uutime = time();
18+ $limtime = $uutime + 31536000;
19+ $result_2 = db_query($conn, "update user_auth_table set lltime_lin = '$uutime' where uname_ch256='$login_user' and pass_ch256='$login_pass';");
20+ $result_3 = db_query($conn, "update user_auth_table set detime_lin = '$limtime' where uname_ch256='$login_user' and pass_ch256='$login_pass';");
21+ $result_4 = db_query($conn, "update user_auth_table set loginstat_in = '1' where uname_ch256='$login_user' and pass_ch256='$login_pass';");
22+
23+ db_free_result($result);
24+ db_free_result($result_2);
25+ db_free_result($result_3);
26+ db_free_result($result_4);
27+ return 0;
28+ }
29+else{
30+ db_free_result($result);
31+ return -3;
32+ }
33+return 0;
34+}
35+
36+
37+
38+function user_logout($login_user, $login_pass)
39+{
40+
41+$conn = db_connect();
42+if(!$conn){
43+ return -1;
44+ }
45+
46+$uutime = time();
47+$result = db_query($conn, "update user_auth_table set lotime_lin = '$uutime' where uname_ch256='$login_user' and pass_ch256='$login_pass';");
48+if(!$result){
49+ return -2;
50+ }
51+else{
52+ $result_2 = db_query($conn, "update user_auth_table set loginstat_in = '2' where uname_ch256='$login_user' and pass_ch256='$login_pass';");
53+ db_free_result($result);
54+ db_free_result($result_2);
55+ return -3;
56+ }
57+
58+return 0;
59+}
60+
61+
62+
63+?>
--- a/ds-apollon/index.php
+++ b/ds-apollon/index.php
@@ -1,6 +1,6 @@
11 <?php
22 // --- コンフィグレーション ---
3-include './include/php/config.inc';
3+include './include/config.inc';
44
55 // --- time zone set ---
66 date_default_timezone_set($__timezone);
@@ -12,21 +12,21 @@ $_pass_word ="";
1212 $_session = 0;
1313
1414 // --- 関数のインクルード ---
15-include './include/php/auth_db.inc';
15+include './include/php/user_auth_db.inc';
16+include './include/php/enco.inc';
17+include './include/php/db.inc';
1618
1719
1820 // --- POST データの処理 ---
1921 if (!empty($_POST)){
20- $SET = htmlspecialchars((int)$_POST["SET"]);
22+ $SET = cmd_replace(htmlspecialchars((int)$_POST["SET"]));
2123 if(preg_match("/^[0-9]+$/", $SET)){ $_set = $SET; } else{ $_set = 0; }
2224
23- $_login_name = htmlspecialchars($_POST["LOGIN_NAME"]);
24- $_pass_word = htmlspecialchars($_POST["PASS_WORD"]);
25+ $_login_name = cmd_replace(htmlspecialchars($_POST["LOGIN_NAME"]));
26+ $_pass_word = cmd_replace(htmlspecialchars($_POST["PASS_WORD"]));
2527 }
2628
2729
28-echo "== index.php ======= _set= $_set _login_name= $_login_name _pass_word= $_pass_word =====<br>\n";
29-
3030 // --- 画面処理 ---
3131 // --- _set0 初期 LOGIN ---
3232 if( $_set == 0 ){
@@ -36,8 +36,7 @@ if( $_set == 0 ){
3636
3737 // --- _set1 認証確認 ---
3838 else if( $_set == 1 ){
39-// if(0 == strcmp("masashi@ms-n.com", $_login_name) && 0 == strcmp("1234567890", $_pass_word)){ // はじめの認証設定
40- if(0 == user_auth_db($_login_name, $_pass_word)){ // はじめの認証設定
39+ if(0 == user_auth_db($_login_name, $_pass_word)){ // 認証設定
4140 include './include/php/session_start.inc'; // セッション 開始処理
4241 $_set = 3;
4342 include './include/html/html_list.inc'; // ログイン完了画面に飛ぶ
@@ -69,6 +68,7 @@ else if( $_set == 3 ){
6968
7069 // --- _set4 ログアウト完了画面---
7170 else if( $_set == 4 ){
71+ user_logout($_login_name, $_pass_word); // 認証設定
7272 include './include/php/session_destroy.inc'; // セッション破壊処理
7373 $_set = 0;
7474 include './include/html/html_logout.inc';
旧リポジトリブラウザで表示