Example #1
0
/**
 *	get html input form token
 *	Note: each access will change
 *
 *	@return
 */
func (ctx *HttpContext) FormTokenHTML() string {
	session, err := ctx.Session(false)
	if nil == session || nil != err {
		return ""
	}
	return `<input type="hidden" name="` + HTML_FORM_TOKEN_NAME + `" value="` + session.FormTokenSignature() + `"/>`
}
Example #2
0
/**
 *	get javascript the out form token, (主要防止页面抓取)
 *	Note: each access will change
 *
 *	@return
 */
func (ctx *HttpContext) FormTokenJavascript() string {
	session, err := ctx.Session(false)
	if nil == session || nil != err {
		return ""
	}

	// `
	// <script type="text/javascript">
	// /*<![CDATA[*/
	// /***********************************************
	// * Encrypt Email script- Please keep notice intact
	// * Tool URL: http://www.dynamicdrive.com/emailriddler/
	// * **********************************************/
	// <!-- Encrypted version of: you [at] **********.*** //-->
	// var emailriddlerarray=[121,111,117,64,121,111,117,114,100,111,109,97,105,110,46,99,111,109]
	// var encryptedemail_id85='' //variable to contain encrypted email
	// for (var i=0; i<emailriddlerarray.length; i++)
	//  encryptedemail_id85+=String.fromCharCode(emailriddlerarray[i])
	// document.write('<a href="mailto:'+encryptedemail_id85+'">Contact Us</a>')
	// /*]]>*/
	// </script>
	// `

	token := session.FormTokenSignature()
	tokenByte := []byte(token)
	tblen := len(tokenByte)
	if 1 == tblen {

	}
	// 参考:http://www.dynamicdrive.com/emailriddler/
	// stript := `<script type="text/javascript"></script>`

	//	TODO 暂时还没有想到好方法实现
	return ""
}
Example #3
0
/**
 *	get string form token
 *	Note: each access will change
 *
 *	@return
 */
func (ctx *HttpContext) FormTokenString() string {
	session, err := ctx.Session(false)
	if nil == session || nil != err {
		return ""
	}
	return session.FormTokenSignature()
}