1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
|
#include <windows.h>
#include <wininet.h>
#include <sstream>
#include <string>
#include <iostream>
#include <stdio.h>
#include <winsock.h>
#include <conio.h>
WSADATA data;
SOCKET winsock;
SOCKADDR_IN sock;
#pragma comment(lib, "wininet")
#pragma comment(lib, "wsock32.lib")
#include <C:\Dev-Cpp\include\mysql.h>
#define OpenWebsite(a) ShellExecute(NULL,"open",a,NULL,NULL,SW_SHOWNORMAL);
using namespace std;
int main() {
MYSQL *conn;
MYSQL_RES *res;
MYSQL_ROW row;
char *server = "localhost";
char *user = "root";
char *password = "";
char *database = "AEX";
conn = mysql_init(0);
if (!mysql_real_connect(conn, server,
user, password, database, 0, NULL, 0)) {
fprintf(stderr, "%s\n", mysql_error(conn));
exit(1);
}
ostringstream strstr;
HINTERNET hInternet, hFile;
DWORD rSize;
char getip[47];
hInternet = InternetOpen(NULL, INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
hFile = InternetOpenUrl(hInternet, "http://icanhazip.com", NULL, 0, INTERNET_FLAG_RELOAD, 0);
InternetReadFile(hFile, &getip, sizeof(getip), &rSize);
getip[rSize] = '\0';
InternetCloseHandle(hFile);
InternetCloseHandle(hInternet);
strstr << "SELECT * FROM users WHERE IP='" + getip +"'" ;
string str = strstr.str();
if(mysql_query(conn, str.c_str())) {
fprintf(stderr, "%s\n", mysql_error(conn));
}
res = mysql_use_result(conn);
while (row = mysql_fetch_row(res)) {
OpenWebsite(row[2]);
std::cout << "WEBSITE: " << row[2] << "";
}
mysql_free_result(res);
mysql_close(conn);
system("PAUSE");
return false;
}
|