Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
张磊
/
FileStorageBeego
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
5be22a99
authored
2014-02-20 13:44:34 +0800
by
slene
Committed by
asta.xie
2014-03-12 15:56:04 +0800
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
fix captcha urlPrefix
1 parent
5d02b18d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
6 deletions
utils/captcha/captcha.go
utils/captcha/captcha.go
View file @
5be22a9
...
...
@@ -67,7 +67,7 @@ const (
fieldIdName
=
"captcha_id"
fieldCaptchaName
=
"captcha"
cachePrefix
=
"captcha_"
urlPrefix
=
"/captcha/"
defaultURLPrefix
=
"/captcha/"
)
// Captcha struct
...
...
@@ -76,7 +76,7 @@ type Captcha struct {
store
cache
.
Cache
// url prefix for captcha image
url
Prefix
string
URL
Prefix
string
// specify captcha id input field name
FieldIdName
string
...
...
@@ -155,7 +155,7 @@ func (c *Captcha) CreateCaptchaHtml() template.HTML {
return
template
.
HTML
(
fmt
.
Sprintf
(
`<input type="hidden" name="%s" value="%s">`
+
`<a class="captcha" href="javascript:">`
+
`<img onclick="this.src=('%s%s.png?reload='+(new Date()).getTime())" class="captcha-img" src="%s%s.png">`
+
`</a>`
,
c
.
FieldIdName
,
value
,
c
.
urlPrefix
,
value
,
c
.
url
Prefix
,
value
))
`</a>`
,
c
.
FieldIdName
,
value
,
c
.
URLPrefix
,
value
,
c
.
URL
Prefix
,
value
))
}
// create a new captcha id
...
...
@@ -224,14 +224,14 @@ func NewCaptcha(urlPrefix string, store cache.Cache) *Captcha {
cpt
.
StdHeight
=
stdHeight
if
len
(
urlPrefix
)
==
0
{
urlPrefix
=
url
Prefix
urlPrefix
=
defaultURL
Prefix
}
if
urlPrefix
[
len
(
urlPrefix
)
-
1
]
!=
'/'
{
urlPrefix
+=
"/"
}
cpt
.
url
Prefix
=
urlPrefix
cpt
.
URL
Prefix
=
urlPrefix
return
cpt
}
...
...
@@ -242,7 +242,7 @@ func NewWithFilter(urlPrefix string, store cache.Cache) *Captcha {
cpt
:=
NewCaptcha
(
urlPrefix
,
store
)
// create filter for serve captcha image
beego
.
AddFilter
(
url
Prefix
+
":"
,
"BeforeRouter"
,
cpt
.
Handler
)
beego
.
AddFilter
(
cpt
.
URL
Prefix
+
":"
,
"BeforeRouter"
,
cpt
.
Handler
)
// add to template func map
beego
.
AddFuncMap
(
"create_captcha"
,
cpt
.
CreateCaptchaHtml
)
...
...
Write
Preview
Styling with
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment