コード例 #1
0
ファイル: juxian.go プロジェクト: navy1125/gameauth
func OnJuXianBill(w http.ResponseWriter, req *http.Request) {
	defer req.Body.Close()
	game_plat := game.GetGameNameByUrl(req.URL.Path) + "_" + game.GetPlatNameByUrl(req.URL.Path)
	qid := req.FormValue("qid")
	order_amount := req.FormValue("order_amount")
	order_id := req.FormValue("order_id")
	server_id := req.FormValue("server_id")
	sign := req.FormValue("sign")
	logging.Debug("juxian request bill:%s,%s,%s", qid, req.RemoteAddr, req.URL.Path)
	hash := md5.New()
	mystr := qid + order_amount + order_id + server_id + config.GetConfigStr(game_plat+"_key")
	io.WriteString(hash, mystr)
	mysign := fmt.Sprintf("%x", hash.Sum(nil))
	if strings.ToLower(mysign) != strings.ToLower(sign) {
		hash.Reset()
		mystr1 := "qid=" + qid + "&order_amount=" + order_amount + "&order_id=" + order_id + "&server_id=" + server_id + "&sign=" + config.GetConfigStr(game_plat+"_key")
		io.WriteString(hash, mystr1)
		mysign := fmt.Sprintf("%x", hash.Sum(nil))
		if strings.ToLower(mysign) != strings.ToLower(sign) {
			hash.Reset()
			mystr2 := "qid=" + qid + "&order_amount=" + order_amount + "&order_id=" + order_id + "&server_id=" + server_id + "&sign=" + config.GetConfigStr(game_plat+"_key")
			io.WriteString(hash, mystr2)
			mysign := fmt.Sprintf("%x", hash.Sum(nil))
			if strings.ToLower(mysign) != strings.ToLower(sign) {
				logging.Debug("md5 check err:%s,%s,%s,%s,%s", mystr, mystr1, mystr2, mysign, sign)
				w.Write([]byte("0"))
				return
			}
		}
	}

	myaccid, err := db.GetMyAccountByAccountId(game.GetPlatNameByUrl(req.URL.Path), qid)
	if err != nil {
		logging.Debug("bill account err:%s", qid)
		w.Write([]byte("3"))
		return
	}
	zoneid, _ := strconv.Atoi(server_id)
	gameid, _ := db.GetZonenameByZoneid(uint32(zoneid))
	logging.Debug("request bill ok:%s,%d,%d,%d", qid, myaccid, gameid, zoneid)
	serverid, _ := strconv.Atoi(server_id)
	server_id = strconv.Itoa((gameid << 16) + serverid)
	names := db.GetAllZoneCharNameByAccid(server_id, myaccid)
	if names == nil || len(names) == 0 {
		logging.Debug("bill checkname err:%d,%s", myaccid, qid)
		w.Write([]byte("3"))
		return
	}
	moneynum, _ := strconv.ParseFloat(order_amount, 32)
	game.Billing(game.GetGameNameByUrl(req.URL.Path), server_id, myaccid, 0, uint32(moneynum*100))
	w.Write([]byte("1"))
}
コード例 #2
0
ファイル: juxian.go プロジェクト: navy1125/gameauth
// juxian game auth
func OnJuXianCheckName(w http.ResponseWriter, req *http.Request) {
	defer req.Body.Close()
	game_plat := game.GetGameNameByUrl(req.URL.Path) + "_" + game.GetPlatNameByUrl(req.URL.Path)
	qid := req.FormValue("qid")
	server_id := req.FormValue("server_id")
	sign := req.FormValue("sign")
	logging.Debug("juxian request checkname:%s,%s,%s", qid, req.RemoteAddr, req.URL.Path)
	hash := md5.New()
	mystr := "qid=" + qid + "&server_id=" + server_id + config.GetConfigStr(game_plat+"_key")
	io.WriteString(hash, mystr)
	mysign := fmt.Sprintf("%x", hash.Sum(nil))
	if strings.ToLower(mysign) != strings.ToLower(sign) {
		hash.Reset()
		mystr1 := "qid=" + qid + "&server_id=" + server_id + "&sign=" + config.GetConfigStr(game_plat+"_key")
		io.WriteString(hash, mystr1)
		mysign := fmt.Sprintf("%x", hash.Sum(nil))
		if strings.ToLower(mysign) != strings.ToLower(sign) {
			hash.Reset()
			mystr2 := qid + server_id + config.GetConfigStr(game_plat+"_key")
			io.WriteString(hash, mystr2)
			mysign := fmt.Sprintf("%x", hash.Sum(nil))
			if strings.ToLower(mysign) != strings.ToLower(sign) {
				logging.Debug("juxian md5 check err:%s,%s,%s,%s,%s", mystr, mystr1, mystr2, mysign, sign)
				ret := ErrorState{Result: "-1"}
				b, _ := json.Marshal(ret)
				w.Write(b)
				return
			}
			return
		}
	}

	//account := qid

	myaccid, err := db.GetMyAccountByAccountId(game.GetPlatNameByUrl(req.URL.Path), qid)
	if err != nil {
		http.Redirect(w, req, config.GetConfigStr(game_plat+"_err"), 303)
		return
	}
	zoneid, _ := strconv.Atoi(server_id)
	gameid, _ := db.GetZonenameByZoneid(uint32(zoneid))
	logging.Debug("request check ok:%s,%d,%d,%d", qid, myaccid, gameid, zoneid)
	serverid, _ := strconv.Atoi(server_id)
	server_id = strconv.Itoa((gameid << 16) + serverid)
	names := db.GetAllZoneCharNameByAccid(server_id, myaccid)
	if names == nil || len(names) == 0 {
		logging.Debug("names err:%d", myaccid)
		ret := ErrorState{Result: "-3"}
		b, _ := json.Marshal(ret)
		w.Write(b)
		return
	}
	nicks := NickNameList{
		Result: "1",
		Data:   make([]NickName, len(names)),
	}
	convert, _ := iconv.Open("GB2312", "UTF-8")
	for i, name := range names {
		charname, _ := convert.ConvString(name.CharName)
		fmt.Println(name.CharId, charname)
		nicks.Data[i].Nickid = name.CharId
		nicks.Data[i].Nickname = charname
	}
	b, _ := json.Marshal(nicks)
	fmt.Println(string(b))
	w.Write(b)
}
コード例 #3
0
ファイル: juxian.go プロジェクト: navy1125/gameauth
func OnJuUcjoyBill(w http.ResponseWriter, req *http.Request) {
	defer req.Body.Close()
	game_plat := game.GetGameNameByUrl(req.URL.Path) + "_" + game.GetPlatNameByUrl(req.URL.Path)
	qid := req.FormValue("accountid")
	gameid := req.FormValue("gameid")
	server_id := req.FormValue("serverid")
	orderid := req.FormValue("orderid")
	order_amount := req.FormValue("point")
	giftcoin := req.FormValue("giftcoin")
	timestamp := req.FormValue("timestamp")
	remark := req.FormValue("remark")
	sign := req.FormValue("sign")
	logging.Debug("ucjoy request bill:%s,%s,%s", qid, req.RemoteAddr, req.URL.Path)
	hash := md5.New()
	mystr := qid + gameid + server_id + orderid + order_amount + giftcoin + timestamp + remark + config.GetConfigStr(game_plat+"_key")
	io.WriteString(hash, mystr)
	mysign := fmt.Sprintf("%x", hash.Sum(nil))
	if strings.ToLower(mysign) != strings.ToLower(sign) {
		logging.Debug("md5 check err:%s,%s,%s", mystr, mysign, sign)
		w.Write([]byte("4"))
		return
	}

	myaccid, err := db.GetMyAccountByAccountId(game.GetPlatNameByUrl(req.URL.Path), qid)
	if err != nil {
		logging.Debug("bill account err:%s", qid)
		w.Write([]byte("3"))
		return
	}
	zoneid, _ := strconv.Atoi(server_id)
	zid := config.GetConfigInt("zqb_zoneid_" + server_id)
	if zid != 0 {
		zoneid = zid
	}
	if zoneid == 11211 {
		zoneid = 11012
	}
	if zoneid == 11238 {
		zoneid = 11013
	}
	if zoneid == 11351 {
		zoneid = 11014
	}
	if zoneid == 11397 {
		zoneid = 11015
	}
	if zoneid == 11396 {
		zoneid = 11999
	}
	if zoneid == 11491 {
		zoneid = 11016
	}
	if zoneid == 11551 {
		zoneid = 11017
	}
	if zoneid == 11592 {
		zoneid = 11018
	}
	if zoneid == 11651 {
		zoneid = 11019
	}
	if zoneid == 11694 {
		zoneid = 11998
	}
	if zoneid == 11771 {
		zoneid = 11020
	}
	if zoneid == 11872 {
		zoneid = 11021
	}
	if zoneid == 11912 {
		zoneid = 11022
	}
	if zoneid == 11931 {
		zoneid = 11023
	}
	if zoneid == 12011 {
		zoneid = 11024
	}
	if zoneid == 12071 {
		zoneid = 11099
	}
	if zoneid == 12091 {
		zoneid = 11025
	}
	if zoneid == 12133 {
		zoneid = 11026
	}
	if zoneid == 12211 {
		zoneid = 11027
	}
	if zoneid == 12220 {
		zoneid = 11098
	}
	mygameid, _ := db.GetZonenameByZoneid(uint32(zoneid))
	logging.Debug("request bill ok:%s,%d,%d,%d", qid, myaccid, mygameid, zoneid)
	serverid := zoneid
	server_id = strconv.Itoa((mygameid << 16) + serverid)
	names := db.GetAllZoneCharNameByAccid(server_id, myaccid)
	if names == nil || len(names) == 0 {
		logging.Debug("bill checkname err:%d,%s", myaccid, qid)
		w.Write([]byte("3"))
		return
	}
	moneynum, _ := strconv.ParseFloat(order_amount, 32)
	game.Billing(game.GetGameNameByUrl(req.URL.Path), server_id, myaccid, 0, uint32(moneynum))
	w.Write([]byte("1"))
}
コード例 #4
0
ファイル: kuaiwan.go プロジェクト: navy1125/gameauth
// juxian game auth
func OnKuaiWanCheckName(w http.ResponseWriter, req *http.Request) {
	defer req.Body.Close()
	logging.Debug("kw request login:%s,%s", req.RemoteAddr, req.URL.Path)
	game_plat := game.GetGameNameByUrl(req.URL.Path) + "_" + game.GetPlatNameByUrl(req.URL.Path)
	account := req.FormValue("login_name")
	game_id := req.FormValue("game_id")
	server_id := req.FormValue("server_id")
	from_id := req.FormValue("from_id")
	sign := req.FormValue("token")
	hash := md5.New()
	mystr := from_id + game_id + account + server_id + config.GetConfigStr(game_plat+"_key")
	io.WriteString(hash, mystr)
	mysign := fmt.Sprintf("%x", hash.Sum(nil))
	if mysign != sign {
		logging.Debug("kuaiwan md5 check err:%s,%s,%s", mystr, mysign, sign)
		ret := ErrorState{Result: "-1"}
		b, _ := json.Marshal(ret)
		w.Write(b)
		return
	}
	if from_id == "" {
		logging.Debug("account err:%s", mystr)
		ret := ErrorState{Result: "-2"}
		b, _ := json.Marshal(ret)
		w.Write(b)
		return
	}
	if account == "" || len(account) > 20 {
		logging.Debug("account err:%s", mystr)
		ret := ErrorState{Result: "-3"}
		b, _ := json.Marshal(ret)
		w.Write(b)
		return
	}

	account = from_id + "_" + account
	_, myaccid, err := db.GetMyAccount(game.GetPlatNameByUrl(req.URL.Path), account, "")
	if err != nil {
		logging.Debug("my account err:%s", account)
		ret := ErrorState{Result: "-3"}
		b, _ := json.Marshal(ret)
		w.Write(b)
		return
	}
	names := db.GetAllZoneCharNameByAccid(server_id, myaccid)
	if names == nil || len(names) == 0 {
		logging.Debug("names err:%d", myaccid)
		ret := ErrorState{Result: "-3"}
		b, _ := json.Marshal(ret)
		w.Write(b)
		return
	}
	nicks := NickNameList{
		Result: "1",
		Data:   make([]NickName, len(names)),
	}
	convert, _ := iconv.Open("GB2312", "UTF-8")
	for i, name := range names {
		charname, _ := convert.ConvString(name.CharName)
		fmt.Println(name.CharId, charname)
		nicks.Data[i].Nickid = name.CharId
		nicks.Data[i].Nickname = charname
	}
	b, _ := json.Marshal(nicks)
	fmt.Println(string(b))
	w.Write(b)
}