Beispiel #1
0
func (c *Controller) ELogin() (string, error) {

	c.r.ParseForm()
	email := c.r.FormValue("email")
	password := c.r.FormValue("password")
	if len(password) > 50 || len(password) < 1 {
		return "", errors.New(c.Lang["invalid_pass"])
	}

	data, err := c.OneRow("SELECT id, salt FROM e_users WHERE email = ?", email).String()
	if err != nil {
		return "", utils.ErrInfo(err)
	}
	if len(data) == 0 {
		return "", errors.New(c.Lang["email_is_not_registered"])
	}

	// проверяем, верный ли пароль
	passAndSalt := utils.Sha256(password + data["salt"])
	userId, err := utils.DB.Single("SELECT id FROM e_users WHERE id  =  ? AND password  =  ?", data["id"], passAndSalt).Int64()
	if err != nil {
		return "", utils.ErrInfo(err)
	}
	if userId == 0 {
		return "", errors.New(c.Lang["wrong_pass"])
	}

	c.sess.Set("e_user_id", userId)

	return utils.JsonAnswer("success", "success").String(), nil
}
Beispiel #2
0
func (c *Controller) EPayeerSign() (string, error) {

	c.r.ParseForm()
	sign := strings.ToUpper(string(utils.Sha256(c.EConfig["payeer_id"] + ":" + c.r.FormValue("m_orderid") + ":" + c.r.FormValue("m_amount") + ":USD:" + c.r.FormValue("m_desc") + ":" + c.EConfig["payeer_s_key"])))
	fmt.Println(sign)
	fmt.Println(c.EConfig["payeer_id"] + ":" + c.r.FormValue("m_orderid") + ":" + c.r.FormValue("m_amount") + ":USD:" + c.r.FormValue("m_desc") + ":" + c.EConfig["payeer_s_key"])
	return sign, nil
}
Beispiel #3
0
func (c *Controller) EGatePayeer() (string, error) {

	c.r.ParseForm()

	fmt.Println(c.r.Form)

	if utils.IPwoPort(c.r.RemoteAddr) != "37.59.221.23" {
		return "", errors.New("Incorrect RemoteAddr " + utils.IPwoPort(c.r.RemoteAddr))
	}

	if len(c.r.FormValue("m_operation_id")) > 0 && len(c.r.FormValue("m_sign")) > 0 {
		sign := strings.ToUpper(string(utils.Sha256(c.r.FormValue("m_operation_id") + ":" + c.r.FormValue("m_operation_ps") + ":" + c.r.FormValue("m_operation_date") + ":" + c.r.FormValue("m_operation_pay_date") + ":" + c.r.FormValue("m_shop") + ":" + c.r.FormValue("m_orderid") + ":" + c.r.FormValue("m_amount") + ":" + c.r.FormValue("m_curr") + ":" + base64.StdEncoding.EncodeToString([]byte(c.r.FormValue("m_desc"))) + ":" + c.r.FormValue("m_status") + ":" + c.EConfig["payeer_s_key"])))
		if c.r.FormValue("m_sign") == sign && c.r.FormValue("m_status") == "success" {

			txTime := utils.Time()

			currencyId := int64(0)

			if c.r.FormValue("m_curr") == "USD" {
				currencyId = 1001
			}
			if currencyId == 0 {
				return c.r.FormValue("m_orderid") + "|success", nil
			}

			amount := utils.StrToFloat64(c.r.FormValue("m_amount"))
			pmId := utils.StrToInt64(c.r.FormValue("m_operation_id"))
			// проверим, не зачисляли ли мы уже это платеж
			existsId, err := c.Single(`SELECT id FROM e_adding_funds_payeer WHERE id = ?`, pmId).Int64()
			if err != nil {
				return c.r.FormValue("m_orderid") + "|success", nil
			}
			if existsId != 0 {
				return c.r.FormValue("m_orderid") + "|success", nil
			}
			paymentInfo := c.r.FormValue("m_desc")

			EPayment(paymentInfo, currencyId, txTime, amount, pmId, "payeer", c.ECommission)
			return c.r.FormValue("m_orderid") + "|success", nil
		}
	}
	return c.r.FormValue("m_orderid") + "|error", nil

}
Beispiel #4
0
func (p *Parser) AdminNewVersionFront() error {

	err := p.generalCheckAdmin()
	if err != nil {
		return p.ErrInfo(err)
	}

	verifyData := map[string]string{"version": "version", "soft_type": "soft_type"}
	err = p.CheckInputData(verifyData)
	if err != nil {
		return p.ErrInfo(err)
	}

	version, err := p.Single("SELECT version FROM new_version WHERE version  =  ?", p.TxMap["version"]).String()
	if err != nil {
		return p.ErrInfo(err)
	}
	if len(version) > 0 {
		return p.ErrInfo("exists version")
	}

	forSign := fmt.Sprintf("%s,%s,%s,%s,%s,%s,%s", p.TxMap["type"], p.TxMap["time"], p.TxMap["user_id"], p.TxMap["soft_type"], p.TxMap["version"], utils.Sha256(p.TxMap["file"]), p.TxMap["format"])
	CheckSignResult, err := utils.CheckSign(p.PublicKeys, forSign, p.TxMap["sign"], false)
	if err != nil {
		return p.ErrInfo(err)
	}
	if !CheckSignResult {
		return p.ErrInfo("incorrect sign")
	}
	return nil
}