Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
B
beego
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
beego
Commits
a54353b5
Commit
a54353b5
authored
Feb 20, 2014
by
slene
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix captcha urlPrefix
parent
060b3211
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
6 deletions
+6
-6
captcha.go
utils/captcha/captcha.go
+6
-6
No files found.
utils/captcha/captcha.go
View file @
a54353b5
...
@@ -67,7 +67,7 @@ const (
...
@@ -67,7 +67,7 @@ const (
fieldIdName
=
"captcha_id"
fieldIdName
=
"captcha_id"
fieldCaptchaName
=
"captcha"
fieldCaptchaName
=
"captcha"
cachePrefix
=
"captcha_"
cachePrefix
=
"captcha_"
urlPrefix
=
"/captcha/"
defaultURLPrefix
=
"/captcha/"
)
)
// Captcha struct
// Captcha struct
...
@@ -76,7 +76,7 @@ type Captcha struct {
...
@@ -76,7 +76,7 @@ type Captcha struct {
store
cache
.
Cache
store
cache
.
Cache
// url prefix for captcha image
// url prefix for captcha image
url
Prefix
string
URL
Prefix
string
// specify captcha id input field name
// specify captcha id input field name
FieldIdName
string
FieldIdName
string
...
@@ -155,7 +155,7 @@ func (c *Captcha) CreateCaptchaHtml() template.HTML {
...
@@ -155,7 +155,7 @@ func (c *Captcha) CreateCaptchaHtml() template.HTML {
return
template
.
HTML
(
fmt
.
Sprintf
(
`<input type="hidden" name="%s" value="%s">`
+
return
template
.
HTML
(
fmt
.
Sprintf
(
`<input type="hidden" name="%s" value="%s">`
+
`<a class="captcha" href="javascript:">`
+
`<a class="captcha" href="javascript:">`
+
`<img onclick="this.src=('%s%s.png?reload='+(new Date()).getTime())" class="captcha-img" src="%s%s.png">`
+
`<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
// create a new captcha id
...
@@ -224,14 +224,14 @@ func NewCaptcha(urlPrefix string, store cache.Cache) *Captcha {
...
@@ -224,14 +224,14 @@ func NewCaptcha(urlPrefix string, store cache.Cache) *Captcha {
cpt
.
StdHeight
=
stdHeight
cpt
.
StdHeight
=
stdHeight
if
len
(
urlPrefix
)
==
0
{
if
len
(
urlPrefix
)
==
0
{
urlPrefix
=
url
Prefix
urlPrefix
=
defaultURL
Prefix
}
}
if
urlPrefix
[
len
(
urlPrefix
)
-
1
]
!=
'/'
{
if
urlPrefix
[
len
(
urlPrefix
)
-
1
]
!=
'/'
{
urlPrefix
+=
"/"
urlPrefix
+=
"/"
}
}
cpt
.
url
Prefix
=
urlPrefix
cpt
.
URL
Prefix
=
urlPrefix
return
cpt
return
cpt
}
}
...
@@ -242,7 +242,7 @@ func NewWithFilter(urlPrefix string, store cache.Cache) *Captcha {
...
@@ -242,7 +242,7 @@ func NewWithFilter(urlPrefix string, store cache.Cache) *Captcha {
cpt
:=
NewCaptcha
(
urlPrefix
,
store
)
cpt
:=
NewCaptcha
(
urlPrefix
,
store
)
// create filter for serve captcha image
// 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
// add to template func map
beego
.
AddFuncMap
(
"create_captcha"
,
cpt
.
CreateCaptchaHtml
)
beego
.
AddFuncMap
(
"create_captcha"
,
cpt
.
CreateCaptchaHtml
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
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 comment