Exemplo n.º 1
0
void Stage0(void) 
{
	char buf[MAXLEN];
	MYSQL_RES *mysql_res;
	MYSQL_ROW row;

	snprintf(buf,MAXLEN,"select phone,memo from VIPMAC where MAC='%s'",MAC);
	mysql_res = ExecSQL(buf,1);
	row = mysql_fetch_row(mysql_res);
	if( row ) {
		snprintf(PHONE,12,row[0]);
		snprintf(buf,MAXLEN,"insert into Log values('%s','%s','%s',now(),'VIP %s auto online 7 day')",
			remote_addr(), MAC, PHONE, row[1]);
		ExecSQL(buf,0);
		IPOnline(7*24*3600);
	}
	snprintf(buf,MAXLEN,"select phone,timestampdiff(second,now(),end) from MACPhone where MAC='%s' and now()< end",MAC);
	mysql_res = ExecSQL(buf,1);
	row = mysql_fetch_row(mysql_res);
	if( row ) {
		snprintf(PHONE,12,row[0]);
		snprintf(buf,MAXLEN,"insert into Log values('%s','%s','%s',now(),'auto online %s sec')",
			remote_addr(), MAC, PHONE, row[1]);
		ExecSQL(buf,0);
		IPOnline(atoi(row[1]));
	}
	DisplayStage('0',NULL,0);	
	exit(0);
}
Exemplo n.º 2
0
void Stage2()			// setonline
{
	char *phone, *password, *p;
	char buf[MAXLEN];
	MYSQL_RES *mysql_res;
	MYSQL_ROW row;
	phone = GetValue("phone");
	if ((phone == NULL) || (phone[0] == 0))
		DisplayStage('0', "输入的电话号码为空", 1);
	CheckPhone(phone);
	strncpy(PHONE, phone, 12);
	password = GetValue("password");
	if ((password == NULL) || strlen(password) != 6)
		DisplayStage('1', "请输入密码", 1);

	snprintf(buf, MAXLEN, "select pass from PhonePass where phone='%s' and valid>now()", phone);
	mysql_res = ExecSQL(buf, 1);
	row = mysql_fetch_row(mysql_res);
	if (row == NULL)
		DisplayStage('0', "未查到一周内的电话号码信息,请重新输入", 1);
	if (strcmp(row[0], password) != 0) {
		DisplayStage('1', "密码错误,请重新输入", 1);
	}

	p = GetValue("timespan");
	if ((p == NULL) || (*p == 0))
		p = "1";
	else
		*(p + 1) = 0;
	if ((*p != '1') && (*p != '7'))
		p = "1";
	snprintf(buf, MAXLEN, "replace into MACPhone values('%s','%s',now(), date_add(now(), interval %s day))", MAC, PHONE, p);
	ExecSQL(buf, 0);
	snprintf(buf, MAXLEN, "insert into Log values('%s','%s','%s',now(),'online %s day')", remote_addr(), MAC, PHONE, p);
	ExecSQL(buf, 0);

	IPOnline((*p - '0') * 24 * 3600);
}