revert captcha, add stuff to js
This commit is contained in:
parent
534e023526
commit
d245462373
@ -993,19 +993,12 @@ func (self httpFrontend) handle_poster(wr http.ResponseWriter, r *http.Request)
|
|||||||
func (self *httpFrontend) serve_captcha(wr http.ResponseWriter, r *http.Request) {
|
func (self *httpFrontend) serve_captcha(wr http.ResponseWriter, r *http.Request) {
|
||||||
s, err := self.store.Get(r, self.name)
|
s, err := self.store.Get(r, self.name)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
id, ok := s.Values["captcha_id"]
|
captcha_id := captcha.New()
|
||||||
if ok {
|
s.Values["captcha_id"] = captcha_id
|
||||||
redirect_url := fmt.Sprintf("%scaptcha/%s.png", self.prefix, id)
|
s.Save(r, wr)
|
||||||
s.Save(r, wr)
|
redirect_url := fmt.Sprintf("%scaptcha/%s.png", self.prefix, captcha_id)
|
||||||
http.Redirect(wr, r, redirect_url, 302)
|
// redirect to the image
|
||||||
} else {
|
http.Redirect(wr, r, redirect_url, 302)
|
||||||
captcha_id := captcha.New()
|
|
||||||
s.Values["captcha_id"] = captcha_id
|
|
||||||
s.Save(r, wr)
|
|
||||||
redirect_url := fmt.Sprintf("%scaptcha/%s.png", self.prefix, captcha_id)
|
|
||||||
// redirect to the image
|
|
||||||
http.Redirect(wr, r, redirect_url, 302)
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
// handle session error
|
// handle session error
|
||||||
// TODO: clear cookies?
|
// TODO: clear cookies?
|
||||||
|
@ -31,7 +31,28 @@ function get_storage() {
|
|||||||
return st;
|
return st;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setSrcQuery(e, q) {
|
||||||
|
var src = e.src;
|
||||||
|
var p = src.indexOf('?');
|
||||||
|
if (p >= 0) {
|
||||||
|
src = src.substr(0, p);
|
||||||
|
}
|
||||||
|
e.src = src + "?" + q
|
||||||
|
}
|
||||||
|
|
||||||
|
function reload(el) {
|
||||||
|
setSrcQuery(el, "reload=" + (new Date()).getTime());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// captcha reload
|
||||||
|
onready(function(){
|
||||||
|
var e = document.getElementById("captcha_img");
|
||||||
|
if (e) {
|
||||||
|
e.onclick = function() {
|
||||||
|
reload(e);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// rewrite all images to add inline expand
|
// rewrite all images to add inline expand
|
||||||
onready(function() {
|
onready(function() {
|
||||||
|
Reference in New Issue
Block a user