//构造登陆返回消息
MSG_ROLE_INFO RoleInfo;
//长度限制
if ( strlen( pMsgLogin->Name ) > MAX_ACCOUNT_SIZE || strlen( pMsgLogin->cPassWord ) > MAX_ACCOUNT_SIZE )
{
RoleInfo.LoginResult=2;
SendMsg(&RoleInfo, (int)Socket );
return false;
}
//帐号限制
for ( int a = 0; a < (int)strlen( pMsgLogin->Name ); a++ )
{
if (!( isalpha( pMsgLogin->Name[a] ) || isdigit( pMsgLogin->Name[a] ) || pMsgLogin->Name[a] == '_' ) )
{
RoleInfo.LoginResult=2;
SendMsg(&RoleInfo, (int)Socket );
return false;
}
}
return true;
}
char* CLogin::GetCurrDateTime()
{
time_t ltime;
time( <ime );
struct tm *pTime;
pTime = ::localtime( <ime ); /* Convert to local time. */
memset(m_DateTime,0L,sizeof(m_DateTime) );
sprintf(m_DateTime, "%4.4d%2.2d%2.2d%2.2d%2.2d%2.2d",pTime->tm_year + 1900, pTime->tm_mon+1, pTime->tm_mday,pTime->tm_hour,pTime->tm_min,pTime->tm_sec);
return m_DateTime;
}
void CLogin::HttpRequest_CheckLogin(int GameServerId,const char * Account, char *PassWord, char* Mac ,int Socket)
{
char pszBuff[512];
char passwordsecond[128];
sprintf(passwordsecond ,"%s%s",m_MD5.MDString(PassWord),"38af86134b65d0f10fe33d30dd76442e");
sprintf(pszBuff,"GET /login.php?t=%s&n=%s&c=%s&p=%s&r=xj01&h=0&m=%s HTTP/1.1\r\nHost: api.176.com\r\nCache-Control: no-cache\r\nConnection: Close\n\r\n",GetCurrDateTime(),Account,m_LocalIp.c_str(), m_MD5.MDString(passwordsecond),Mac);
string str=HTTP_Connect(m_HttpServerIp.c_str(),m_HttpServerPort, pszBuff,strlen(pszBuff));
Http_ReslovePacket(str,Socket,GameServerId);
}
以上部分是C++的代码!需要写出PHP的代码
实现这个登录验证的功能!GET /login.php?t=%s&n=%s&c=%s&p=%s&r=xj01&h=0&m=%s
MSG_ROLE_INFO RoleInfo;
//长度限制
if ( strlen( pMsgLogin->Name ) > MAX_ACCOUNT_SIZE || strlen( pMsgLogin->cPassWord ) > MAX_ACCOUNT_SIZE )
{
RoleInfo.LoginResult=2;
SendMsg(&RoleInfo, (int)Socket );
return false;
}
//帐号限制
for ( int a = 0; a < (int)strlen( pMsgLogin->Name ); a++ )
{
if (!( isalpha( pMsgLogin->Name[a] ) || isdigit( pMsgLogin->Name[a] ) || pMsgLogin->Name[a] == '_' ) )
{
RoleInfo.LoginResult=2;
SendMsg(&RoleInfo, (int)Socket );
return false;
}
}
return true;
}
char* CLogin::GetCurrDateTime()
{
time_t ltime;
time( <ime );
struct tm *pTime;
pTime = ::localtime( <ime ); /* Convert to local time. */
memset(m_DateTime,0L,sizeof(m_DateTime) );
sprintf(m_DateTime, "%4.4d%2.2d%2.2d%2.2d%2.2d%2.2d",pTime->tm_year + 1900, pTime->tm_mon+1, pTime->tm_mday,pTime->tm_hour,pTime->tm_min,pTime->tm_sec);
return m_DateTime;
}
void CLogin::HttpRequest_CheckLogin(int GameServerId,const char * Account, char *PassWord, char* Mac ,int Socket)
{
char pszBuff[512];
char passwordsecond[128];
sprintf(passwordsecond ,"%s%s",m_MD5.MDString(PassWord),"38af86134b65d0f10fe33d30dd76442e");
sprintf(pszBuff,"GET /login.php?t=%s&n=%s&c=%s&p=%s&r=xj01&h=0&m=%s HTTP/1.1\r\nHost: api.176.com\r\nCache-Control: no-cache\r\nConnection: Close\n\r\n",GetCurrDateTime(),Account,m_LocalIp.c_str(), m_MD5.MDString(passwordsecond),Mac);
string str=HTTP_Connect(m_HttpServerIp.c_str(),m_HttpServerPort, pszBuff,strlen(pszBuff));
Http_ReslovePacket(str,Socket,GameServerId);
}
以上部分是C++的代码!需要写出PHP的代码
实现这个登录验证的功能!GET /login.php?t=%s&n=%s&c=%s&p=%s&r=xj01&h=0&m=%s