luwenna пре 3 година
родитељ
комит
aa4057d288

+ 7 - 0
src/jfw/filter/pcfilter.go

@@ -7,6 +7,7 @@ import (
 	"jfw/public"
 	"net/http"
 	"qfw/util"
+	"qfw/util/jy"
 	"qfw/util/redis"
 	"strings"
 	"time"
@@ -38,11 +39,17 @@ func (this *pcFilter) Do() bool {
 	if strings.HasPrefix(this.R.RequestURI, "/jypc/toAct/") {
 		return true
 	}
+
 	href := "/?nol=1"
 	//对比session是否一致,不一致则清除掉sessionid
 	if uid := this.GetSession["userId"]; uid != nil && uid != "" {
 		userid, _ := uid.(string)
 		sessid := fmt.Sprint(this.Session.Id())
+		//i_unlimited :登录限制
+		if i_unlimited := util.IntAll(this.GetSession["i_unlimited"]); i_unlimited > 0 {
+			jy.PutLoginSess(public.MQFW, util.ObjToString(config.Sysconfig["appPushServiceRpc"]), sessid, userid, util.IntAll(config.Sysconfig["criticality"]), i_unlimited)
+			return true
+		}
 		//老用户没有LoginRedisKey的创建key
 		if sid := redis.Get("other", jyutil.LoginRedisKey(userid)); sid == nil {
 			redis.Put("other", jyutil.LoginRedisKey(userid), sessid, 3600*util.IntAllDef(config.Sysconfig["pcSessionTimeout"], 168))

+ 5 - 4
src/jfw/front/front.go

@@ -645,6 +645,7 @@ func (f *Front) SignOut() error {
 	userId, _ := f.GetSession("userId").(string)
 	if userId != "" {
 		redis.Del("other", jyutil.LoginRedisKey(userId))
+		jy.DelUnlimitSessionId(fmt.Sprint(f.Session().Id()), userId) //多账号
 	}
 	f.DelSession("rpcBackUserInfo")
 	f.DelSession("user")
@@ -816,10 +817,10 @@ func CreateSession(q map[string]interface{}, sess *httpsession.Session, typ stri
 	//
 	if pcSessionFlag, ok := config.Sysconfig["pcSessionFlag"].(bool); pcSessionFlag && ok && flag {
 		userid := util.ObjToString(sessionVal["userId"])
-		// sidStr := fmt.Sprint(sess.Id())
-		// jyutil.ClearPcSession(userid, sidStr)
-		log.Println("sess:", sess.Id(), q["_id"])
-		redis.Put("other", jyutil.LoginRedisKey(userid), sess.Id(), 3600*util.IntAllDef(config.Sysconfig["pcSessionTimeout"], 168))
+		//无限制登陆用户
+		if util.IntAll(sessionVal["i_unlimited"]) <= 0 {
+			redis.Put("other", jyutil.LoginRedisKey(userid), sess.Id(), 3600*util.IntAllDef(config.Sysconfig["pcSessionTimeout"], 168))
+		}
 	}
 	sessionVal["platform"] = typ
 	sess.SetMultiple(sessionVal)

+ 2 - 1
src/jfw/jyutil/jyutil.go

@@ -161,7 +161,7 @@ func Getopenid(code string) (openid string) {
 
 //
 func GetSessionVal(q map[string]interface{}) (*map[string]interface{}, map[string]interface{}) {
-	person, ok := public.MQFW.FindOneByField("user", q, `{"_id":1,"i_shareknow":1,"s_m_openid":1,"s_nickname":1,"s_headimage":1,"s_headimageurl":1,"s_phone":1,"s_m_phone":1,"l_registedate":1,"b_merge_remind":1,"i_ispush":1}`)
+	person, ok := public.MQFW.FindOneByField("user", q, `{"_id":1,"i_shareknow":1,"s_m_openid":1,"s_nickname":1,"s_headimage":1,"s_headimageurl":1,"s_phone":1,"s_m_phone":1,"l_registedate":1,"b_merge_remind":1,"i_ispush":1,"i_unlimited":1}`)
 	sessionVal := make(map[string]interface{})
 	if !ok || person == nil || len(*person) == 0 {
 		return nil, sessionVal
@@ -191,6 +191,7 @@ func GetSessionVal(q map[string]interface{}) (*map[string]interface{}, map[strin
 		phone = util.ObjToString((*person)["s_m_phone"])
 	}
 	sessionVal["phone"] = phone
+	sessionVal["i_unlimited"] = util.IntAll((*person)["i_unlimited"])
 	return person, sessionVal
 }
 

+ 6 - 0
src/jfw/jyutil/sessionkeep.go

@@ -78,6 +78,12 @@ func (sk *SessionKeep) Do() bool {
 			} else {
 				if flag == 2 {
 					_, sessionVal := GetSessionVal(map[string]interface{}{"_id": StringTOBsonId(deuserid)})
+					//未登陆账号
+					if i_unlimited, ok := sessionVal["i_unlimited"].(int); i_unlimited > 0 && ok {
+						http.SetCookie(sk.W, sk.cookie("", SKCookieName))
+						http.Redirect(sk.W, sk.R, "/", 302)
+						return false
+					}
 					for k, v := range sessionVal {
 						sk.SetSession[k] = v
 					}

+ 39 - 16
src/jfw/modules/app/src/app/front/login.go

@@ -51,7 +51,6 @@ type Login struct {
 	afterPageLoadToCheck xweb.Mapper `xweb:"/jyapp/free/afterPageLoadToCheck"` //检测
 	channelSign          xweb.Mapper `xweb:"/jyapp/free/channelSign"`          //渠道统计
 	savePushIdMsg        xweb.Mapper `xweb:"/jyapp/free/savePushIdMsg"`        //推送id记录
-	tes                  xweb.Mapper `xweb:"/jyapp/free/tes"`
 }
 
 var (
@@ -71,14 +70,7 @@ func init() {
 	}
 	go rs.GC()
 }
-func (l *Login) Tes() {
-	//uid: 5d9fe93a27573439d033b294 QQtJCABNAVEDAkFYQ1pWTVYAAgYWXUla
-	// u_secure := BsonIdToSId(person["_id"]) //Ql9FD1wRUFNQVENfEgoGRQQCUlFHCUNa
-	// simpleuid := qutil.SE.EncodeString(BsonIdToSId(person["_id"]))
-	// log.Println("uid:", u_secure, simpleuid)
-	log.Println(qutil.SE.DecodeString("Ql9FD1wRUFNQVENfEgoGRQQCUlFHCUNa"))
-	log.Println(qutil.SE.DecodeString("QQtJCABNAVEDAkFYQ1pWTVYAAgYWXUla"))
-}
+
 func (l *Login) Login() error {
 	defer qutil.Catch()
 	if l.Method() == "GET" {
@@ -756,6 +748,7 @@ func (l *Login) SignOut() {
 			}
 		}()
 	}
+	jy.DelUnlimitSessionId(fmt.Sprint(l.Session().Id()), userid) //多账号
 	ClearSession(l.Session())
 	l.ServeJson(map[string]interface{}{
 		"status": status,
@@ -833,7 +826,7 @@ func (l *Login) AfterPageLoadToCheck() {
 			},
 			"$pull": map[string]interface{}{"a_jpushid": rid},
 		})
-		sign = createSign(userId, rid, "更新极光id后")
+		sign = createSign(userId, rid, "更新极光id后", l.Session())
 	}
 	l.ServeJson(map[string]interface{}{
 		"status":       status,
@@ -849,7 +842,7 @@ func (l *Login) Brand() {
 		if !checkIsKicked(false, u.UserId, u.Rid, l.Session()) {
 			jgPushId := l.GetString("jgPushId")
 			setMobileInfo(u.UserId, l.GetString("phoneBrand"), l.GetString("pushToken"), jgPushId)
-			sign = createSign(u.UserId, jgPushId, "设置手机类型和推送id后")
+			sign = createSign(u.UserId, jgPushId, "设置手机类型和推送id后", l.Session())
 		}
 	}
 	l.ServeJson(map[string]interface{}{
@@ -920,7 +913,7 @@ func createSession(s *httpsession.Session, person map[string]interface{}, loginI
 		default:
 			return false
 		}
-		field := `{"s_m_openid":1,"s_phone":1,"s_jpushid":1,"s_opushid":1,"s_appponetype":1,"s_headimageurl":1,"s_phone":1,"s_nickname":1,"s_appversion":1}`
+		field := `{"s_m_openid":1,"s_phone":1,"s_jpushid":1,"s_opushid":1,"s_appponetype":1,"s_headimageurl":1,"s_phone":1,"s_nickname":1,"s_appversion":1,"i_unlimited":1}`
 		data, ok := mongodb.FindOneByField("user", query, field)
 		if !ok {
 			return false
@@ -947,6 +940,7 @@ func createSession(s *httpsession.Session, person map[string]interface{}, loginI
 	s.Set("s_appponetype", person["s_appponetype"])
 	s.Set("s_appversion", person["s_appversion"])
 	s.Set("s_headimageurl", strings.Replace(qutil.ObjToString(person["s_headimageurl"]), "http://", "https://", 1))
+	s.Set("i_unlimited", qutil.IntAll(person["i_unlimited"]))
 	if qutil.ObjToString(person["s_phone"]) != "" {
 		phone := person["s_phone"].(string)
 		s.Set("s_phone", phone)
@@ -974,6 +968,17 @@ func createSession(s *httpsession.Session, person map[string]interface{}, loginI
 		Expires:  expires,
 	}
 	http.SetCookie(rw, c)
+	//多账号登陆用户
+	i_unlimited := qutil.IntAll(person["i_unlimited"])
+	if i_unlimited > 0 {
+		uid := BsonIdToSId(person["_id"])
+		jy.PutLoginSess(mongodb, qutil.ObjToString(config.Sysconfig["appPushServiceRpc"]), fmt.Sprint(s.Id()), uid, qutil.IntAll(config.Sysconfig["criticality"]), i_unlimited)
+		redis.Put("other", fmt.Sprintf("app_%s", fmt.Sprint(s.Id())), &jy.AppLoginPush{
+			JgPushId:    qutil.ObjToString(person["s_jpushid"]),
+			OtherPushId: qutil.ObjToString(person["s_opushid"]),
+			PhoneType:   qutil.ObjToString(person["s_appponetype"]),
+		}, 86400*30)
+	}
 	return true
 }
 
@@ -1003,11 +1008,11 @@ func ClearSession(s *httpsession.Session) {
 	s.Del("phoneAuthTime")
 	s.Del("mailAuthTime")
 	s.Del("phone")
-
+	s.Del("i_unlimited")
 }
 
 //生成签名,返回手机端
-func createSign(userid, rid, signType string) string {
+func createSign(userid, rid, signType string, session *httpsession.Session) string {
 	u := &UserSign{
 		UserId:     userid,
 		CreateTime: time.Now().Unix(),
@@ -1033,14 +1038,22 @@ func getSign(u *UserSign) (string, string) {
 
 //
 func afterLogin(user map[string]interface{}, session *httpsession.Session, rid, oid, phoneType, channel, deviceId string, isNewUser bool, rw http.ResponseWriter) string {
+	log.Println("===>", fmt.Sprint(session.Id()))
 	userid := BsonIdToSId(user["_id"])
 	old_rid, _ := user["s_jpushid"].(string)
 	old_oid, _ := user["s_opushid"].(string)
 	old_ponetype, _ := user["s_appponetype"].(string)
+	off := true
 	go func() {
 		if !isNewUser {
+			if rd, ok := mongodb.FindById("user", userid, `{"i_unlimited":1}`); ok && rd != nil && len(*rd) > 0 {
+				i_unlimited := qutil.IntAll((*rd)["i_unlimited"])
+				if i_unlimited > 0 {
+					off = false
+				}
+			}
 			//同一账号在不同设备登录,极光id不一样,给之前的设备推送自定义的下线消息,离线消息保持10天
-			if old_rid != "" && old_rid != rid {
+			if old_rid != "" && old_rid != rid && off {
 				mongodb.UpdateById("user", userid, map[string]interface{}{
 					"$addToSet": map[string]interface{}{"a_jpushid": old_rid},
 				})
@@ -1115,7 +1128,7 @@ func afterLogin(user map[string]interface{}, session *httpsession.Session, rid,
 	user["s_opushid"] = oid
 	user["s_appponetype"] = phoneType
 	createSession(session, user, "", 0, rw)
-	return createSign(userid, rid, "登录后")
+	return createSign(userid, rid, "登录后", session)
 }
 
 //清空这个rid
@@ -1151,6 +1164,16 @@ func autoLogin(sign, from string, session *httpsession.Session, rw http.Response
 	if fromIsRestart && checkIsKicked(true, u.UserId, u.Rid, session) {
 		return -3
 	}
+	// //解析签名时 查看该签名是否被标记下线 如果被标记 则退出
+	// signKey := fmt.Sprintf("app_%s", fmt.Sprint(session.Id()))
+	// log.Println("key:", signKey)
+	// if data := redis.Get("other", signKey); data != nil {
+	// 	rdata := qutil.ObjToMap(data)
+	// 	ok, _ := (*rdata)["ok"].(bool)
+	// 	if sign == qutil.ObjToString((*rdata)["sign"]) && !ok {
+	// 		return -3
+	// 	}
+	// }
 	if createSession(session, nil, u.UserId, 0, rw) {
 		return 1
 	}

+ 6 - 5
src/jfw/modules/app/src/config.json

@@ -1,10 +1,10 @@
 {
-	"cookiedomain": ".jianyu360.cn",
+	"cookiedomain": ".jianyu360.com",
 	"webport": "89",
 	"weixinrpc": "127.0.0.1:8083",
 	"cacheflag": false,
 	"agreement": "http",
-	"webdomain": "https://wcj.jydev.jianyu360.com",
+	"webdomain": "https://web-zxl.jydev.jianyu360.com",
 	"redirect": {
 		"wxpushlist": "/jyapp/wxpush/bidinfo/%s",
 		"newInfoFollow": "/jyapp/followent/newInfo/%s",
@@ -111,7 +111,7 @@
 		"shareTimesUpperLimitR": 4000,
 		"shareTimesUpperLimitIrr": 1000
 	},
-	"appPushServiceRpc": "192.168.17.53:5565",
+	"appPushServiceRpc": "192.168.20.139:5566",
 	"afterSavePushId": 60,
 	"mail": [
     {
@@ -147,7 +147,7 @@
 	"termValidity": 3600,
 	"uploadPath": "./web/staticres/jyapp/res/",
 	"appConfig":{
-		"pushGrpcServer":"192.168.3.11:5565",
+		"pushGrpcServer":"192.168.20.139:5565",
 		"pushGrpcHeartBeat":3
 	},
     "redisSessionLockSize":20,
@@ -158,5 +158,6 @@
     "maxBindPop":8,
     "bindPopRedis":"merge",
     "phoneFilterFlag":true,
-    "optimalTime":"2021-08-03 12:00:00"
+    "optimalTime":"2021-08-03 12:00:00",
+    "criticality":2
 }

+ 8 - 0
src/jfw/modules/app/src/web/staticres/jyapp/js/common.js

@@ -750,6 +750,14 @@ var Verification = {
     return /^[1][3-9][0-9]{9}$/.test(value);
   }
 }
+
+//深信服用户开了一批特殊规则的手机号
+var CreatePhone = {
+  //自己创建的手机号验证[格式为100xxxxxxxx]
+  isPhone: function (value) {
+    return /^[1][0][0][0-9]{8}$/.test(value);
+  }
+}
 // 部分页面没有全局工具函数
 if (typeof utils !== 'object') {
   utils = {}

+ 2 - 2
src/jfw/modules/app/src/web/templates/me/login.html

@@ -201,7 +201,7 @@
 					return
 				}
 				var phone = $.trim($("#tel").val());
-				if(!Verification.isPhone(phone)){
+				if((!Verification.isPhone(phone))||(!CreatePhone.isPhone(phone))){
 					EasyAlert.show("手机号格式错误");
 					return
 				}
@@ -374,7 +374,7 @@
 				dcsOne = false;
 	     		$("#sendIdentCode").css("color","#888888")
 			}
-			if($.trim(phone).length > 0 && Verification.isPhone(phone)){
+			if($.trim(phone).length > 0 && (Verification.isPhone(phone) || CreatePhone.isPhone(phone))){
 				if($(".header-tab>a.header-tab-active").index() == 0){
 					if($.trim(password).length > 0 && password.length >= 6){
 						$("#btn").removeClass("disabled");

+ 142 - 0
src/jfw/modules/common/src/qfw/util/jy/jy.go

@@ -12,8 +12,11 @@ import (
 	"net/url"
 	"qfw/util"
 	"qfw/util/mail"
+	"qfw/util/redis"
+	qrpc "qfw/util/rpc"
 	"qfw/util/sms"
 	"regexp"
+	"sort"
 	"strings"
 	"time"
 	"unicode"
@@ -320,3 +323,142 @@ func GetMonth(mon string) int {
 	}
 	return month[mon]
 }
+
+//value unlimited 并发限制登陆用户
+func LoginRedisKey(userid string) string {
+	return fmt.Sprintf("unlimited_%s", userid)
+}
+
+//获取loginSess
+func GetLoginSess(userid string) []string {
+	key := LoginRedisKey(userid)
+	if data, ok := redis.Get("other", key).([]interface{}); ok {
+		return util.ObjArrToStringArr(data)
+	}
+	return []string{}
+}
+
+//判断是否在内
+func IsInLoginSess(key string, arr []string) bool {
+	for _, v := range arr {
+		if key == v {
+			return true
+		}
+	}
+	return false
+}
+
+type TtlMap struct {
+	key   string //sessionid
+	value int    //ttl
+}
+
+type AppLoginPush struct {
+	JgPushId    string `json:"jpushId"`
+	OtherPushId string `json:"opushId"`
+	PhoneType   string `json:"phoneType"`
+}
+
+//更新存储用户sessionid的队列 【sessionid ttl小于三天的清除】  key:sessionid
+func PutLoginSess(mongodb MongodbSim, apppushRpc, key, userid string, limit, max int) bool {
+	value := GetLoginSess(userid)
+	if !IsInLoginSess(key, value) {
+		value = append(value, key)
+	}
+	ttlmap := []TtlMap{}
+	if len(value) >= int(limit*max/100) {
+		new_value := []string{}
+		//如果已存的session大于限制 则清除三天后到期的session
+		for _, vv := range value {
+			ttl := redis.GetTTL("session", vv)
+			if ttl <= 86400*1 && ttl != -1 {
+				// if ttl <= 600 && ttl != -1 {
+				if ok := redis.Del("session", vv); ok {
+					LoginOutPush(mongodb, userid, vv, apppushRpc)
+					log.Println(fmt.Sprintf("%s用户的sessionid 到期时间还有%v 小于三天 清除 %s", userid, ttl, vv))
+				}
+				continue
+			}
+			new_value = append(new_value, vv)
+			ttlmap = append(ttlmap, TtlMap{vv, int(ttl)})
+		}
+		value = new_value
+	}
+	//清除并发最大限制的某个sessionid
+	if len(value) > max {
+		//排序 获取马上过期的session 清除
+		sort.Slice(ttlmap, func(i, j int) bool {
+			return ttlmap[i].value < ttlmap[j].value
+		})
+		if len(ttlmap) > 0 {
+			//清除sessionid
+			delId := ttlmap[0].key
+			redis.Del("session", delId)
+			value = removeArr(value, delId)
+			LoginOutPush(mongodb, userid, delId, apppushRpc)
+			log.Println(fmt.Sprintf("%s用户的sessionid 超过最大限制 清除 %s ,到期时间%v", userid, delId, ttlmap[0].value))
+			for _, v := range ttlmap {
+				log.Println(v.key, "===", v.value)
+			}
+		}
+	}
+	return redis.Put("other", LoginRedisKey(userid), value, -1)
+}
+
+//清除数组中的s
+func removeArr(arr []string, s string) []string {
+	result := []string{}
+	for _, v := range arr {
+		if v == s {
+			continue
+		}
+		result = append(result, v)
+	}
+	return result
+}
+
+//
+func LoginOutPush(mongodb MongodbSim, userid, sessid, apppushRpc string) {
+	rediskey := fmt.Sprintf("app_%s", sessid)
+	r := redis.Get("other", rediskey)
+	if r == nil {
+		return
+	}
+	arr, err := json.Marshal(r)
+	if err != nil {
+		log.Println("json Marshal err:", err)
+	}
+	apppush := AppLoginPush{}
+	// 反序列化
+	err2 := json.Unmarshal(arr, &apppush)
+	if err2 != nil {
+		log.Println("json Unmarshal err:", err)
+	}
+	mongodb.UpdateById("user", userid, map[string]interface{}{
+		"$addToSet": map[string]interface{}{"a_jpushid": apppush.JgPushId},
+	})
+	//
+	log.Println("多账号登陆:", userid, apppush.PhoneType, apppush.JgPushId, apppush.OtherPushId, "踢人下线")
+	ok := qrpc.AppPush(apppushRpc, map[string]interface{}{
+		"type":        "signOut",
+		"descript":    "您的账号在其他设备登录,如有需要请重新登录。",
+		"jgPushId":    apppush.JgPushId,
+		"otherPushId": apppush.OtherPushId,
+		"phoneType":   apppush.PhoneType,
+		"userId":      userid,
+	})
+	log.Println("ok:", ok)
+}
+
+//session数组清除某个value[针对多账号同时在线的方法、退出登录时调用]
+func DelUnlimitSessionId(sessid, userid string) []string {
+	sessArr := GetLoginSess(userid)
+	newArr := []string{}
+	for _, v := range sessArr {
+		if v == sessid {
+			continue
+		}
+		newArr = append(newArr, v)
+	}
+	return newArr
+}

+ 20 - 0
src/jfw/modules/sxfUser/src/config.json

@@ -0,0 +1,20 @@
+{
+	"mysql":{
+		"dbName": "bxt",
+	    "address": "192.168.3.242:3306",
+	    "userName": "root",
+	    "passWord": "Topnet123",
+		"maxOpenConns": 5,
+		"maxIdleConns": 5
+	},
+	"mongodb":{
+		"address": "192.168.3.206:27080",
+ 		"size": 5,
+		"dbName": "qfw",
+		"replSet": ""
+	},
+	"user":[
+		"1109222"
+	],
+	"limit":100
+}

+ 73 - 0
src/jfw/modules/sxfUser/src/db/db.go

@@ -0,0 +1,73 @@
+package db
+
+import (
+	"log"
+	"mongodb"
+	qutil "qfw/util"
+	"qfw/util/mysql"
+)
+
+var Mysql *mysql.Mysql
+var Config *config
+
+var Mgo mongodb.MongodbSim
+
+type config struct {
+	Mysql   *mysqlConf `json:"mysql"`
+	MgoCfig *mgoConf   `json:"mongodb"`
+	User    []string   `json:"user"`
+	Limit   int        `json:"limit"`
+}
+
+type mysqlConf struct {
+	DbName       string
+	Address      string
+	UserName     string
+	PassWord     string
+	MaxOpenConns int
+	MaxIdleConns int
+}
+
+type mgoConf struct {
+	Address           string
+	Size              int
+	DbName            string
+	ReplSet           string
+	UserName          string
+	Password          string
+	Collection        string
+	Collection_change string
+}
+
+//
+func init() {
+	//程序配置文件
+	qutil.ReadConfig(&Config)
+	//InitMysql(Config.Mysql.Address, Config.Mysql.PassWord, Config.Mysql.DbName)
+	InitMongodb(Config.MgoCfig.Address, Config.MgoCfig.DbName, Config.MgoCfig.ReplSet, Config.MgoCfig.Size)
+}
+
+//初始化Mysql
+func InitMysql(mysql_addr, mysql_pwd, dbname string) {
+	Mysql = &mysql.Mysql{
+		Address:      mysql_addr,
+		UserName:     "root",
+		PassWord:     mysql_pwd,
+		DBName:       dbname,
+		MaxOpenConns: 50,
+		MaxIdleConns: 20,
+	}
+	Mysql.Init()
+	log.Println("初始化 mysql")
+}
+
+func InitMongodb(addr, dbname, replset string, size int) {
+	Mgo = mongodb.MongodbSim{
+		MongodbAddr: addr,
+		Size:        size,
+		DbName:      dbname,
+		ReplSet:     replset,
+	}
+	Mgo.InitPool()
+	log.Println("初始化 mongodb")
+}

+ 68 - 0
src/jfw/modules/sxfUser/src/main.go

@@ -0,0 +1,68 @@
+package main
+
+import (
+	. "db"
+	"flag"
+	"log"
+	"time"
+)
+
+func main() {
+	modle := flag.Int("m", 0, "默认:0;1 已有账号修限制登陆权益;2 新账号设置登陆权益 ;")
+	flag.Parse()
+	if *modle == 1 {
+		do()
+	} else if *modle == 2 {
+		do2()
+	}
+}
+
+func do() {
+	if len(Config.User) > 0 {
+		for _, v := range Config.User {
+			ok := Mgo.Update("user", map[string]interface{}{
+				"i_appid": 2,
+				"$or": []map[string]interface{}{
+					map[string]interface{}{
+						"s_phone": v,
+					},
+					map[string]interface{}{
+						"s_m_phone": v,
+					},
+				},
+			}, map[string]interface{}{
+				"$set": map[string]interface{}{
+					"i_unlimited": Config.Limit,
+				},
+			}, false, false)
+			if !ok {
+				log.Println(v, "失败")
+			} else {
+				log.Println(v, "成功")
+			}
+		}
+	}
+}
+
+func do2() {
+	if len(Config.User) > 0 {
+		for _, v := range Config.User {
+			id := Mgo.Save("user", map[string]interface{}{
+				"l_registedate": time.Now().Unix(),
+				"s_phone":       v,
+				"o_jy": map[string]interface{}{
+					"i_apppush":    1,
+					"i_ratemode":   2,
+					"l_modifydate": time.Now().Unix(),
+				},
+				"i_appid":     2,
+				"i_unlimited": Config.Limit,
+			})
+			if id == "" {
+				log.Println(v, "失败")
+			} else {
+				log.Println(v, "成功")
+			}
+		}
+	}
+}

+ 3 - 1
src/web/staticres/js/login.js

@@ -1167,7 +1167,9 @@ $(function(){
 
     // 表单规则
     function ruleForPhone (data, type) {
-        var checkStatus = /^[1][3-9][0-9]{9}$/.test(data.value)
+    		var phoneReg = /^[1][3-9][0-9]{9}$/.test(data.value);
+		var createPhoneReg =/^[1][0][0][0-9]{8}$/.test(data.value);
+        var checkStatus =  phoneReg || createPhoneReg;
         if (type === 'input') {
             return data.value.length >= 11 ? checkStatus : true
         }