@@ -451,7 +451,7 @@ KBEEmailVerificationTableMysql::~KBEEmailVerificationTableMysql()
451451}
452452
453453// -------------------------------------------------------------------------------------
454- bool KBEEmailVerificationTableMysql::queryAccount (DBInterface * dbi, const std::string& name, ACCOUNT_INFOS & info)
454+ bool KBEEmailVerificationTableMysql::queryAccount (DBInterface * dbi, int8 type, const std::string& name, ACCOUNT_INFOS & info)
455455{
456456 std::string sqlstr = " select code, datas from kbe_email_verification where accountName like \" " ;
457457
@@ -487,7 +487,7 @@ bool KBEEmailVerificationTableMysql::queryAccount(DBInterface * dbi, const std::
487487}
488488
489489// -------------------------------------------------------------------------------------
490- bool KBEEmailVerificationTableMysql::logAccount (DBInterface * dbi, ACCOUNT_INFOS & info)
490+ bool KBEEmailVerificationTableMysql::logAccount (DBInterface * dbi, int8 type, ACCOUNT_INFOS & info)
491491{
492492 std::string sqlstr = " insert into kbe_email_verification (accountName, datas, code, logtime) values(" ;
493493
@@ -562,7 +562,7 @@ bool KBEEmailVerificationTableMysql::activateAccount(DBInterface * dbi, const st
562562 mysql_free_result (pResult);
563563 }
564564
565- if (logtime > 0 && time (NULL ) - logtime > g_kbeSrvConfig.emailServerInfo_ .deadline )
565+ if (logtime > 0 && time (NULL ) - logtime > g_kbeSrvConfig.emailAtivationInfo_ .deadline )
566566 return false ;
567567
568568 if (info.name .size () == 0 )
@@ -630,7 +630,7 @@ bool KBEEmailVerificationTableMysql::activateAccount(DBInterface * dbi, const st
630630
631631 try
632632 {
633- delAccount (dbi, info.name );
633+ delAccount (dbi, (int8) V_TYPE_CREATEACCOUNT , info.name );
634634 }
635635 catch (...)
636636 {
@@ -640,7 +640,7 @@ bool KBEEmailVerificationTableMysql::activateAccount(DBInterface * dbi, const st
640640}
641641
642642// -------------------------------------------------------------------------------------
643- bool KBEEmailVerificationTableMysql::delAccount (DBInterface * dbi, const std::string& name)
643+ bool KBEEmailVerificationTableMysql::delAccount (DBInterface * dbi, int8 type, const std::string& name)
644644{
645645 std::string sqlstr = " delete from kbe_email_verification where accountName=" ;
646646
@@ -651,8 +651,12 @@ bool KBEEmailVerificationTableMysql::delAccount(DBInterface * dbi, const std::st
651651
652652 sqlstr += " \" " ;
653653 sqlstr += tbuf;
654- sqlstr += " \" " ;
654+ sqlstr += " \" , and type= " ;
655655
656+ kbe_snprintf (tbuf, MAX_BUF , " %d" , type);
657+ sqlstr += tbuf;
658+ sqlstr += " )" ;
659+
656660 SAFE_RELEASE_ARRAY (tbuf);
657661
658662 if (!dbi->query (sqlstr.c_str (), sqlstr.size (), false ))
@@ -668,6 +672,7 @@ bool KBEEmailVerificationTableMysql::syncToDB(DBInterface* dbi)
668672
669673 std::string sqlstr = " CREATE TABLE IF NOT EXISTS kbe_email_verification "
670674 " (accountName varchar(255) not null,"
675+ " type tinyint not null DEFAULT 0,"
671676 " datas varchar(255),"
672677 " code varchar(255), PRIMARY KEY idKey (code),"
673678 " logtime bigint(20) not null DEFAULT 0)"
@@ -676,9 +681,19 @@ bool KBEEmailVerificationTableMysql::syncToDB(DBInterface* dbi)
676681 ret = dbi->query (sqlstr.c_str (), sqlstr.size (), true );
677682 KBE_ASSERT (ret);
678683
679- // 删除24小时之前的记录
680- sqlstr = " delete from kbe_email_verification where logtime<" ;
681- sqlstr += KBEngine::StringConv::val2str (time (NULL ) - g_kbeSrvConfig.emailServerInfo_ .deadline );
684+ // 删除xx小时之前的记录
685+ sqlstr = (boost::format (" delete from kbe_email_verification where logtime<%1% and type=%2%" ) %
686+ KBEngine::StringConv::val2str (time (NULL ) - g_kbeSrvConfig.emailAtivationInfo_ .deadline ) %
687+ ((int8)KBEEmailVerificationTable::V_TYPE_CREATEACCOUNT )).str ();
688+
689+ sqlstr = (boost::format (" delete from kbe_email_verification where logtime<%1% and type=%2%" ) %
690+ KBEngine::StringConv::val2str (time (NULL ) - g_kbeSrvConfig.emailResetPasswordInfo_ .deadline ) %
691+ ((int8)KBEEmailVerificationTable::V_TYPE_RESETPASSWORD )).str ();
692+
693+ sqlstr = (boost::format (" delete from kbe_email_verification where logtime<%1% and type=%2%" ) %
694+ KBEngine::StringConv::val2str (time (NULL ) - g_kbeSrvConfig.emailBindInfo_ .deadline ) %
695+ ((int8)KBEEmailVerificationTable::V_TYPE_BIND_MAIL )).str ();
696+
682697 ret = dbi->query (sqlstr.c_str (), sqlstr.size (), true );
683698 KBE_ASSERT (ret);
684699 return ret;
0 commit comments