Untitled

mail@pastecode.io avatar
unknown
plain_text
7 months ago
2.7 kB
7
Indexable
Never
	if (pInfo(peer)->isNew) {
								add_reg(pInfo(peer)->tankIDName);
								pInfo(peer)->isNew = false;
				}

					if (check_reg(peer)) {
								string error = "action|log\nmsg|CT:[S]_ `4Can not make new account!`` Sorry, but you are not permitted to create new accounts at this time. (This can be because there is an open proxy/VPN here or abuse has from this IP) Please try again from another device or IP Address.";
								packet_(peer, error, "");
								enet_peer_disconnect_later(peer, 0);
								break;
}

void add_reg(const string& name) {

	json data;
	ifstream player("players/" + name + "_.json", ifstream::binary);
	player >> data;
	player.close();
	ofstream add("db/reg.txt", ios::app);
	if (add.fail()) return;
	string anan;
	anan += name + " >> ";
	if (data["mac"] != "02:00:00:00:00:00") anan += data["mac"];
	if (data["wk"] != "NONE0") anan += data["wk"];
	if (!data["gid"].empty()) anan += data["gid"];
	if (!data["rid"].empty()) anan += data["rid"];
	if (!data["vid"].empty()) anan += data["vid"];
	if (!data["aid"].empty()) anan += data["aid"];
	if (!data["ip"].empty()) anan += data["ip"];
	anan += "\n";
	add << anan;
	add.close();

}

bool check_reg(ENetPeer* peer) {

	string line;
	ifstream device("db/reg.txt");
	if (device.fail() || device.peek() == std::ifstream::traits_type::eof()) {
		device.close();
		return false;
	}

	while (getline(device, line)) {
		if (line.find(pInfo(peer)->ip) != string::npos && !pInfo(peer)->ip.empty() || line.find(pInfo(peer)->vid) != string::npos && !pInfo(peer)->vid.empty() || line.find(pInfo(peer)->aid) != string::npos && !pInfo(peer)->aid.empty() || line.find(pInfo(peer)->wk) != string::npos && !pInfo(peer)->wk.empty() || line.find(pInfo(peer)->mac) != string::npos && !pInfo(peer)->mac.empty() || line.find(pInfo(peer)->rid) != string::npos && !pInfo(peer)->rid.empty() || line.find(pInfo(peer)->gid) != string::npos && !pInfo(peer)->gid.empty()) {
			device.close();
			return true;
		}
	}

	device.close();
	return false;

}

if (check_perma(p_, "acc.txt")) {
				enet_peer_disconnect_later(p_, 0);
				return;
				//extra onlem
}

int reg = 0;
ifstream getreg("registered/" + pInfo(p_)->ip + ".txt");
getreg >> reg;
getreg.close();

if (reg < 3) {
				ofstream wr_ip("registered/" + pInfo(p_)->ip + ".txt");
				wr_ip << reg + 1;
				wr_ip.close();
}

if (reg + 1 == 2) pInfo(p_)->isNew = true;
					

	p_->isNew = r_["isNew"].get<bool>();
			

if (lw_time + 1000 < (duration_cast<milliseconds>(system_clock::now().time_since_epoch())).count())
{
	lw_time = (duration_cast<milliseconds>(system_clock::now().time_since_epoch())).count();