forked from supermy/mytools
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
125 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
|
||
location /hello1 { | ||
|
||
default_type 'text/plain'; | ||
|
||
echo "hello jamesmo!"; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
--单行注释 | ||
--[[ | ||
多行注释 | ||
--]] | ||
--变量和程序流程控制 | ||
num = 42 --所有的数值都是双精度的 | ||
-- 别吓一跳,64位的双精度需要52位 | ||
s = 'walternate' --字符串常量 | ||
t = "也可以使用双引号" | ||
u = [[在开始和解释使用 | ||
标识多行字符串 | ||
]] | ||
t = nil | ||
while num < 50 do | ||
num = num +1 | ||
end | ||
|
||
if num > 40 then | ||
print ('over 40') | ||
elseif s ~= 'walternate' then | ||
io.write('not over 40\n') | ||
else | ||
thisGlobal = 5 | ||
|
||
local line = io.read() | ||
print ('Winter is coming,' .. line) | ||
end | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
ngx.log(ngx.ERR,">>>111") | ||
|
||
local secretkey='1234567890abcdefghi' | ||
|
||
local expiretime = ngx.time() | ||
expiretime = expiretime+86400 | ||
expiretime = ngx.cookie_time(expiretime) | ||
|
||
|
||
if ngx.var.cookie_uid == nil or ngx.var.cookie_nickname == nil or ngx.var.cookie_token == nil then | ||
ngx.log(ngx.ERR,">>>222") | ||
ngx.req.set_header("Check-Login", "NULL") | ||
ngx.req.set_header("Foo", {"a", "abc"}) | ||
|
||
ngx.header["Set-Cookie"] = {"Check-Login=NULL" .. "; expires=" .. expiretime ..";path=/" } | ||
|
||
return | ||
end | ||
|
||
local ctoken = ngx.md5('uid:' .. ngx.var.cookie_uid .. '&nickname:' .. ngx.var.cookie_nickname .. '&secretkey:' .. secretkey) | ||
|
||
ngx.log(ngx.ERR,">>>333") | ||
|
||
if ctoken == ngx.var.cookie_token then | ||
ngx.req.set_header("Check-Login", "Yes") | ||
|
||
ngx.header["Set-Cookie"] = {"Check-Login=Yes" .. "; expires=" .. expiretime ..";path=/" } | ||
|
||
ngx.log(ngx.ERR,">>>444") | ||
else | ||
ngx.req.set_header("Check-Login", "No") | ||
|
||
ngx.header["Set-Cookie"] = {"Check-Login=No" .. "; expires=" .. expiretime ..";path=/" } | ||
|
||
ngx.log(ngx.ERR,">>>555") | ||
|
||
end | ||
|
||
return | ||
|
||
--curl -v "http://192.168.59.103/hello1" | ||
--token 错误测试 | ||
--curl -v -b "uid=12345;nickname=soga;token=aa6f21ec0fcf008aa5250904985a817b" "http://192.168.59.103/hello1" | ||
--token 正确测试 | ||
--curl -v -b "uid=1234;nickname=soga;token=aa6f21ec0fcf008aa5250904985a817b" "http://192.168.59.103/hello1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql" %> | ||
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> | ||
|
||
<sql:query var="rs" dataSource="jdbc/TestDB"> | ||
select id, foo, bar from testdata | ||
</sql:query> | ||
|
||
<html> | ||
<head> | ||
<title>DB Test</title> | ||
</head> | ||
<body> | ||
|
||
<h2>Results</h2> | ||
|
||
<c:forEach var="row" items="${rs.rows}"> | ||
Foo ${row.foo}<br/> | ||
Bar ${row.bar}<br/> | ||
</c:forEach> | ||
|
||
获取header 设置的值 | ||
<%=request.getHeader("Check-Login")%> | ||
|
||
|
||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters