📄 gpms.cpp
字号:
str[y] = '\0';
return ((char *) str);
}
//股票关键字解析
int AnalyStock(const char * s, string & retStockStr , int & iType )
{
string sStock = s; //转为大写
sStock = RSapce(sStock.c_str(), false);
int len = sStock.length();
if(0 == len){
return 0;
}
static const basic_string <char>::size_type npos = -1;//cannot be found
basic_string <char>::size_type ret1=sStock.find("GP");
basic_string <char>::size_type ret2=sStock.find("gp");
basic_string <char>::size_type ret3=sStock.find("STOCK");
basic_string <char>::size_type ret4=sStock.find("stock");
basic_string <char>::size_type ret5=sStock.find("股票");
basic_string <char>::size_type ret6=sStock.find("上证指数");
basic_string <char>::size_type ret7=sStock.find("上证");
basic_string <char>::size_type ret8=sStock.find("深证指数");
basic_string <char>::size_type ret9=sStock.find("深证");
char szWebFile[50] ={0};
if( ret1 != npos )
{
retStockStr = sStock ;
retStockStr.replace(ret1,2,"");
sprintf(szWebFile , "http://quote.jrj.com.cn//htmdata/html/%s.htm",retStockStr.c_str() );
retStockStr = szWebFile;
iType = 1 ;
return 1;
}
else if(ret2 != npos )
{
retStockStr = sStock ;
retStockStr.replace(ret2,2,"");
sprintf(szWebFile , "http://quote.jrj.com.cn//htmdata/html/%s.htm",retStockStr.c_str() );
retStockStr = szWebFile;
iType = 1 ;
return 1;
}
else if(ret3 != npos )
{
retStockStr = sStock ;
retStockStr.replace(ret3,5,"");
sprintf(szWebFile , "http://quote.jrj.com.cn//htmdata/html/%s.htm",retStockStr.c_str() );
retStockStr = szWebFile;
iType = 1 ;
return 1;
}
else if(ret4 != npos )
{
retStockStr = sStock ;
retStockStr.replace(ret4,5,"");
sprintf(szWebFile , "http://quote.jrj.com.cn//htmdata/html/%s.htm",retStockStr.c_str() );
retStockStr = szWebFile;
iType = 1 ;
return 1;
}
else if(ret5 != npos )
{
retStockStr = sStock ;
retStockStr.replace(ret5,4,"");
sprintf(szWebFile , "http://quote.jrj.com.cn//htmdata/html/%s.htm",retStockStr.c_str() );
retStockStr = szWebFile;
iType = 1 ;
return 1;
}
else if( ret6 != npos )
{
retStockStr = sStock ;
retStockStr ="http://quote.jrj.com.cn/htmdata/html/03.htm";
iType = 2 ;
return 1;
}
else if(ret7 != npos )
{
retStockStr = sStock ;
retStockStr ="http://quote.jrj.com.cn/htmdata/html/03.htm";
iType = 2 ;
return 1;
}
else if(ret8 != npos )
{
retStockStr = sStock ;
retStockStr ="http://quote.jrj.com.cn/htmdata/html/04.htm";
iType = 2 ;
return 1;
}
else if(ret9 != npos )
{
retStockStr = sStock ;
retStockStr ="http://quote.jrj.com.cn/htmdata/html/04.htm";
iType = 2 ;
return 1;
}
else
return -1;
}
//天气关键字解析
int AnalyWeather(const char * s , string &strWheather)
{
string sStock = s;
sStock = RSapce(sStock.c_str(), false);
int len = sStock.length();
if(0 == len)
{
return 0;
}
static const basic_string <char>::size_type npos = -1;//cannot be found
basic_string <char>::size_type ret1=sStock.find("TQ");
basic_string <char>::size_type ret2=sStock.find("tq");
basic_string <char>::size_type ret3=sStock.find("今天天气");
basic_string <char>::size_type ret4=sStock.find("明天天气");
basic_string <char>::size_type ret5=sStock.find("后天天气");
basic_string <char>::size_type ret6=sStock.find("今日天气");
basic_string <char>::size_type ret7=sStock.find("明日天气");
basic_string <char>::size_type ret8=sStock.find("后日天气");
basic_string <char>::size_type ret9=sStock.find("天气");
if( ret1 != npos )
{
strWheather = sStock ;
strWheather.replace(ret1,2,""); //TQ
return 0;
}
else if(ret2 != npos )
{
strWheather = sStock ;
strWheather.replace(ret2,2,""); //tq
return 0;
}
else if(ret3 != npos )
{
strWheather = sStock ;
strWheather.replace(ret3,8,""); //今天天气
return 1;
}
else if(ret4 != npos )
{
strWheather = sStock ;
strWheather.replace(ret4,8,""); //明天天气
return 2;
}
else if(ret5 != npos )
{
strWheather = sStock ;
strWheather.replace(ret5,8,""); //后天天气
return 3;
}
else if( ret6 != npos )
{
strWheather = sStock ;
strWheather.replace(ret6,8,"");
return 1;
}
else if(ret7 != npos )
{
strWheather = sStock ;
strWheather.replace(ret7,8,"");
return 2;
}
else if(ret8 != npos )
{
strWheather = sStock ;
strWheather.replace(ret8,8,""); //后日天气
return 3;
}
else if(ret9 != npos )
{
strWheather = sStock ;
strWheather.replace(ret9,4,""); //天气
return 0;
}
else
return -1;
}
int IACShell(const string & sTelCode , const string & sMobile, string &strContent, const string & sLinkID, string &sSender)
{
AdoSQL *pAdoSQL ;
pAdoSQL = new AdoSQL();
int iRet =0;
if(pAdoSQL->ExcuteIACShell(sTelCode.c_str() ,sMobile.c_str() , strContent ,sLinkID.c_str(), sSender, iRet))
return iRet;
else
return -1 ;
}
int AnalyseXiabanFun( const string & sMobile, string &strContent ,const string & sLinkID ,string &sSender, const string strContentOrigin )
{
static const basic_string <char>::size_type npos = -1;
basic_string <char>::size_type ret1=strContent.find("DJ");
basic_string <char>::size_type ret2=strContent.find("JF");
basic_string <char>::size_type ret3=strContent.find("XBK");
basic_string <char>::size_type ret4=strContent.find("下班卡");
basic_string <char>::size_type ret5=strContent.find("CZMM");
basic_string <char>::size_type ret6=strContent.find("CA");
basic_string <char>::size_type ret7=strContent.find("YC");
basic_string <char>::size_type ret8=strContent.find("SA");
basic_string <char>::size_type ret9=strContent.find("TD");
//basic_string <char>::size_type ret91=strContent.find_first_of("00000");
AdoSQL *pAdoSQL ;
pAdoSQL = new AdoSQL();
if( ret1 != npos || ret2 != npos || ret6 != npos || ret7 != npos || ret8 != npos || ret9 != npos /*|| ret91 != npos*/) //兑奖 or 积分
{
if(!pAdoSQL->Excu_CTSI_SMS_Insert_Shell_IAC(sLinkID.c_str(), sMobile.c_str(), strContent ))
{
//如果执行过程失败,返回-1;
return -1;
}
return 0;
}
else if( ret3 != npos || ret4 != npos ) //下载下班卡
{
strContent = "下班卡是一张打折卡,你可以在加盟商家消费时候出示即可得到折扣。1 下载绅士卡 2 下载丽人卡";
sSender ="80";
return 0;
}
else if(ret5 != npos)
{
strContent = strContentOrigin ;
strContent.replace(ret5,4,"");
int iPwdLen = strContent.length();
Log("begin post www.xiaban.com");
char szPost[512]={0};
string strGet;
//http://www.xiaban.com/services/srv_city_tong.php?key=123456&module=resetpassword&mobile=13959279487&password=123456
sprintf(szPost,"http://www.xiaban.com/services/srv_biz_xiaban.php?key=123456&module=resetpassword&mobile=%s&password=%s&encode=gb2312",sMobile.c_str(), strContent.c_str());
if(!getHTTPFile(szPost , strGet, 80) )
{
Sleep(10);
Log("modify pwd post www.xiaban.com failed mobile:%s",sMobile );
//服务器异常,请稍后再试。
strContent = "服务器异常,请稍后再试。";
//strcpy(*sContent , strContent.c_str());
//strcpy(*sSender , strSender.c_str());
return 0;
}
else
{
CPacket inPacket;
int iRet = inPacket.BuiltTree(strGet.c_str(),strGet.size());//生成DOM树结构.
if (-1 == iRet)
{
Log("moify pwd post www.xiaban.com failed mobile:%s",sMobile );
return 0;
}
DOMElement* AccNode = NULL;
AccNode = inPacket.SearchElement("/XIABAN/RtnInfo/ReturnValue");
string strRetVal = AccNode->getTextContent();
if("200" == strRetVal)
{
//modify pwd success!
inPacket.ResetCurrentNode();
AccNode = inPacket.SearchElement("/XIABAN/Result/msg_to_client");
string strRetInfo = AccNode->getTextContent();
strContent = strRetInfo;
//strcpy(*sSender , strSender.c_str());
Log("post successfule...");
return 0;
}
else
{
inPacket.ResetCurrentNode();
AccNode = inPacket.SearchElement("/XIABAN/RtnInfo/ReturnInfo");
string strRetInfo = AccNode->getTextContent();
strContent = strRetInfo;
}
}
return 0;
}
return -1;
}
int XiabanInterface(const char * szTelCode, const string strMobile, string &strContent, const string strLinkID, string &strSender, int iType /*处理类型*/)
{
pAdoSQL = new AdoSQL();
char szPost[256]={0};
string strGet;
sprintf(szPost,"http://www.xiaban.com/services/srv_biz_xiaban.php?key=123456&module=registermobile&mobile=%s&encode=gb2312",strMobile.c_str());
if(!getHTTPFile(szPost , strGet, 80) )
{
Sleep(10);
Log("register post http://www.xiaban.com/services/srv_biz_xiaban.php failed mobile:%s",strMobile.c_str() );
//服务器异常,请稍后再试。
strContent = "连接服务器异常,请稍后再试。";
return 0;
}
else
{
CPacket inPacket;
int iRet = inPacket.BuiltTree(strGet.c_str(),strGet.size());
if (-1 == iRet)
{
strContent = "服务器异常,请稍后再试。";
//strcpy(*sContent , strContent.c_str());
Log("Get XML string error! post http://www.xiaban.com/services/srv_biz_xiaban.php mobile:%s",strMobile.c_str() );
return 0;
}
DOMElement* AccNode = NULL;
AccNode = inPacket.SearchElement("/XIABAN/Result/password");
string strPWD = AccNode->getTextContent();
inPacket.ResetCurrentNode();
AccNode = inPacket.SearchElement("/XIABAN/Result/ReturnValue");
int iBizID, RetVal;
char buffer[20] ={0};
if( pAdoSQL->ExcuSP_Pro_IAC_GetBiz_Shell(szTelCode, strMobile.c_str(), strContent, strLinkID.c_str(),strSender,iBizID, RetVal))
{
if( 1== RetVal)
{
_itoa( iBizID, buffer, 10 );
}
else
{
return -1;
}
}
char cResultString[5]= {0};
char *szTemp = NULL;
CMd5A md5;
szTemp = md5.MDString((char *)strMobile.c_str());
cResultString[0] = szTemp[2];
cResultString[1] = szTemp[6];
cResultString[2] = szTemp[14];
cResultString[3] = szTemp[16];
if(90 == iType) //处理sender为90的业务
{
//"XZK"+" "+"mobile的md5"+ " " +商家ID
strContent ="XZK ";
strContent += cResultString;
strContent += " ";
strContent += buffer;
}
else //处理sender为80的业务
{
//"XZK"+" "+"mobile的md5"+ " " +商家ID
char szCont[256]={0};
sprintf(szCont,"XBK %s %s",cResultString, strContent.c_str() );
strContent = szCont ;
}
if( 0 == strcmp("1" , AccNode->getTextContent()))
{
char szTemp[512]= {0};
if(!pAdoSQL->Excu_CTSI_SMS_Insert_Shell_IAC(strLinkID.c_str() , strMobile.c_str() , strContent ))
{
sprintf(szTemp, "服务器异常,请稍后再试。我们已免费帮你注册下班网(xiaban.com)帐号%s,密码%s", strMobile , strPWD.c_str());
strContent = szTemp;
return 0;
}
sprintf(szTemp, "。我们已免费帮你注册下班网(xiaban.com)帐号%s,密码%s。WAPPUSH下载卡http://biz.xiaban.com/mcard/mycard.aspx?m=%s&k=%s", strMobile.c_str(), strPWD.c_str(), strMobile.c_str(), cResultString);
strContent = strContent + szTemp;
//strcpy(*sContent , strContent.c_str());
//strcpy(*sSender , strSender.c_str());
return 0;
}
else
{
if(!pAdoSQL->Excu_CTSI_SMS_Insert_Shell_IAC(strLinkID.c_str() , strMobile.c_str() , strContent ))
{
strContent ="服务器异常,请稍后再试!" ;
//strcpy(*sContent , strContent.c_str());
//strcpy(*sSender , strSender.c_str());
return 0;
}
char szUnReg[512]={0};
sprintf(szUnReg,"。如果你的手机已安装移动卡夹,请运行并点击刷新,就可以看到下载的VIP卡。|WAPPUSH下载移动卡夹http://biz.xiaban.com/mcard/mycard.aspx?m=%s&k=%s", strMobile.c_str(), cResultString);
strContent += szUnReg;
//strcpy(*sContent , strContent.c_str());
//strcpy(*sSender , strSender.c_str());
return 0;
}
}
return 1;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -