kk Blog —— 通用基础


date [-d @int|str] [+%s|"+%F %T"]
netstat -ltunp
sar -n DEV 1

nignx log_format 日志时间格式

https://bnxb.com/nginx/27544.html

Nginx的默认访问日志的时间格式是:[08/Mar/2018:10:30:58 +0800],由日志参数中的$time_local变量表示。

改成常用格式:2018-06-08 10:11:23

有两种方法,一种是修改源码,然后编译,一种是外挂lua来实现

一、lua 方法

不修改 nginx 源代码的,具体如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
http {
	log_format  main  '$fmt_localtime $request_time $server_addr $server_port $remote_addr $remote_port $status $body_bytes_sent $request_method $server_protocol'
			  ' "$host" "$uri" "$query_string" "$http_referer" "$http_user_agent" "$http_x_forwarded_for" - $remote_user';

	access_log  /var/log/nginx/access.log  main;

	map $host $fmt_localtime {
		default '';
	}
	log_by_lua_block {
		ngx.var.fmt_localtime = ngx.localtime();
	}
	...
}

代码的解释如下:

首先我们自定义一个nginx 变量 $fmt_localtime , 因为在http context不能够使用 set $variable。

所以我们采用map的方式如下

1
2
3
map $host $fmt_localtime {
	default '';
}

2) 然后我们用 log_by_lua_block 设置 ngx.fmt_localtime 的时间

3) 设置日志格式 log_format使用 $fmt_localtime 作为时间参数

二、修改nginx源代码

需要修改的文件

src/core/nginx_times.c

src/http/modules/ngx_http_log_module.c

首先修改ngx_http_log_module.c文件:

1
ngx_string("time_iso8601"), sizeof("1970-09-28T12:00:00+06:00") - 1,

更改后

1
ngx_string("time_iso8601"), sizeof("1970-09-28 12:00:00") - 1,

然后修改nginx_times.c文件:

1
[sizeof("1970-09-28T12:00:00+06:00")];

更改后

1
[sizeof("1970-09-28 12:00:00")];
1
ngx_cached_http_log_iso8601.len = sizeof("1970-09-28T12:00:00+06:00") - 1;

更改为

1
ngx_cached_http_log_iso8601.len = sizeof("1970-09-28 12:00:00") - 1;
1
2
3
4
5
6
(void) ngx_sprintf(p3, "%4d-%02d-%02dT%02d:%02d:%02d%c%02d:%02d",
		tm.ngx_tm_year, tm.ngx_tm_mon,
		tm.ngx_tm_mday, tm.ngx_tm_hour,
		tm.ngx_tm_min, tm.ngx_tm_sec,
		tp->gmtoff < 0 ? '-' : '+',
		ngx_abs(tp->gmtoff / 60), ngx_abs(tp->gmtoff % 60));

更改为

1
2
3
4
(void) ngx_sprintf(p3, "%4d-%02d-%02d %02d:%02d:%02d",
		tm.ngx_tm_year, tm.ngx_tm_mon,
		tm.ngx_tm_mday, tm.ngx_tm_hour,
		tm.ngx_tm_min, tm.ngx_tm_sec);

最后重新编译,并使用新的时间变量

将 nginx 配置文件中的 $time_local 改为 $time_iso8601 即可。

用html+css+js实现一个无限级树形控件

http://t.zoukankan.com/rxbook-p-10975673.html

gg.html

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
<!DOCTYPE html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title>树形菜单示例</title>

	<style type="text/css">
	ul>li {
		list-style: none;
	}

	/* 可展开*/
	.switch-open {
		margin-left:-12px;
		border:6px solid transparent;
		display:inline-block;
		height:0px;
		border-top-color: black;
	}

	/* 展开完毕*/
	.switch-close {
		margin-left:-12px;
		border:6px solid transparent;
		display:inline-block;
		height:0px;
		border-left-color: black;
		margin-bottom: 2px;

	}
	/* 改变CheckBox样式*/
	input[type='checkbox'] {
		height: 20px;

		-webkit-appearance:none;
		-moz-appearance: none;
		border: 1px solid #c9c9c9;
		border-radius: 3px;
		outline: none;
		color:white;
		text-align: center;
	}
	input[type='checkbox']:before {
		content: '√ ';
		color:transparent;
	}
	input[type=checkbox]:checked {
		background-color: #30add6;
	}
	input[type=checkbox]:checked:before {
		content: '√';
		color:white;
		font-weight: bold;
	}

	</style>
</head>

<body>

<div class="warp">
	<ul id="container">
	</ul>
</div>

<script type="text/javascript">

	//结构
	var json = {
		'0-0': {
			'0-0-0': {},
			'0-0-1': {
				'0-0-1-0': {},
				'0-0-1-1': {},
				'0-0-1-2': {}
			},
			'0-0-2': {}
		},
		'0-1': {
			'0-1-0': {},
			'0-1-1': {}
		},
		'0-2': {}
	};

	//这里生成DOM
	function generate(json, par)
	{
		for (var attr in json) {
			var ele = document.createElement('li');
			if (json[attr].length > 0) {
				ele.innerHTML = ' <input type="checkbox"></input>'+attr;
			} else {
				ele.innerHTML = '<span><span class="switch-open" onclick="toggle(this)"></span><input type="checkbox" onclick="checkChange(this)"></input>'+attr+'</span>';
				var nextpar = document.createElement('ul');
				ele.appendChild(nextpar);
				generate(json[attr], nextpar);
			}
			par.appendChild(ele);
		}
	}

	generate(json, document.getElementById('container'));


	//处理展开和收起
	function toggle(eve)
	{
		var par = eve.parentNode.nextElementSibling;
		if (par.style.display == 'none') {
			par.style.display = 'block';
			eve.className = 'switch-open';
		} else {
			par.style.display = 'none';
			eve.className = 'switch-close';
		}
	}

	//处理全部勾选和全部不选
	function checkChange(eve)
	{
		var oul = eve.parentNode.nextElementSibling;
		if (eve.checked) {
			for (var i = 0; i < oul.querySelectorAll('input').length; i++) {
				oul.querySelectorAll('input')[i].checked = true;
			}
		} else {
			for (var i = 0; i < oul.querySelectorAll('input').length; i++) {
				oul.querySelectorAll('input')[i].checked = false;
			}
		}
	}

</script>

</body>
</html>

两个 table 实现固定列

https://blog.csdn.net/psp0001060/article/details/49705247

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head> 
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
  <title>固定列头</title> 
  <script src="/rs/js/jquery.min.js" type="text/javascript"></script>
  <style type="text/css">

	.ui-table {
		border-collapse: collapse;
		width:100%;
		white-space: nowrap;
	}
	.ui-table th {
		border: 1px solid #ffffff;
		padding: 1px;
		text-align: center;
		height: 28px;
	}
	.ui-table td {
		border: 1px solid #ffffff;
		background-color: #eeeeee;
		padding: 3px;
		height: 28px;
	}
	div.x_auto_box {
		position: absolute;
		z-index: 1;
	}

	div.lock_box {
		float: left;
		position: sticky;
		left: 0;
		z-index: 5;

	}
	</style> 
 </head> 
 <body> 
  <!-- 左侧DIV --> 
  <div id="list" > 
   <div class="lock_box" style='display: inline-block'> 
    <table class="ui-table"> 
     <thead>
      <tr> 
       <td>No号</td> 
       <td>员工号</td> 
       <td>部门</td> 
      </tr> 
     </thead>
     <tbody>
<?php
	for ($i = 0; $i < 30; $i ++) {
		echo "<tr>";
		echo "<td>$i</td>";
		echo "<td>DHL130023</td>";
		echo "<td>动画联盟</td>";
		echo "</tr>";
	}
?>
     </tbody>
    </table> 
   </div> 

   <!-- 右侧 --> 
   <div class="x_auto_box" id="showDiv" style='display: inline-block'> 
<?php
	for ($i = 0; $i < 30; $i ++) {
		echo '<input type="hidden" name="dto.position" value="1" />';
	}
?>
    <table id="tableRight" class="ui-table"> 
     <thead>
      <tr> 
       <td>性别</td> 
       <td>出生日期</td> 
       <td>民族</td> 
       <td>籍贯</td> 
       <td>婚姻状况</td> 
       <td>学历</td> 
       <td>职位</td> 
       <td>毕业院校</td> 
       <td>专业</td> 
       <td>院校类别</td> 
       <td>毕业日期</td> 
       <td>年龄</td> 
       <td>户籍地址</td> 
       <td>入职时间</td> 
       <td>转正日期</td> 
       <td>本单位工龄</td> 
       <td>合同签订</td> 
       <td>合同年限</td> 
       <td>日语等级</td> 
       <td>社保账号</td> 
       <td>公积金帐号</td> 
       <td>身份证号</td> 
       <td>毕业证书</td> 
       <td>离职时间</td> 
       <td>离职原因</td> 
       <td>户口性质</td> 
       <td>政治面貌</td> 
       <td>参加工作</td> 
       <td>联系电话</td> 
       <td>邮箱</td> 
       <td>家庭住址</td> 
       <td>办公电话</td> 
       <td>备注</td> 
      </tr>
     </thead>
     <tbody>
<?php
$h = <<<here
      <tr οnclick="javascript:window.location.href='/HRMS2/pages/personManageInfo.jsp?userid=SX00001'"> 
       <td>男</td> 
       <td></td> 
       <td></td> 
       <td></td> 
       <td>未婚</td> 
       <td>小学</td> 
       <td>普通员工</td> 
       <td></td> 
       <td></td> 
       <td>专升本</td> 
       <td></td> 
       <td>0</td> 
       <td></td> 
       <td></td> 
       <td></td> 
       <td>0.0</td> 
       <td></td> 
       <td>0</td> 
       <td>四级</td> 
       <td></td> 
       <td></td> 
       <td></td> 
       <td></td> 
       <td></td> 
       <td></td> 
       <td>非农业户口</td> 
       <td>民主党派</td> 
       <td></td> 
       <td></td> 
       <td></td> 
       <td></td> 
       <td></td> 
       <td></td> 
      </tr> 
here;
	for ($i = 0; $i < 30; $i ++) {
		echo $h;
	}
?>
     </tbody>
    </table> 
   </div> 
  </div>  
 </body>
</html>