ANCIENT DRAGON .. YOUR THE BOMB :). I was so frustrated with linker issues. LOL.. I hated code blocks... at first :), but how I ever so love the auto brackets and it's assistance I took so forgranted with DEV-c++. Now I have my game cheats I develop and am dying to share in control. I am using this feature as a simple basic but effective database to share the cheats I made for a game without worrying of my enemy players using them against me all in the while I learned more programming and became of greater market value in the world.
THANKS, you have solved many posts for me AD.
Now so what I have learned and how far I came in a few days time I am sharing in case someone else needs this useful example code.
///////////////////////////////////////////////////////////////////////////////////
///////////////////Developed By: Cody Oebel aka MANEGARD ////////////////////////////
////////////////////////// A.k.a DRAXZ ////////////////////////////
///////////////////////////////////////////////////////////////////////////
#include <windows.h>
#include <WinInet.h>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
//HINTERNET hInternet;
string GetLocalComputerName();
ifstream in;
ofstream out;
int main()
{
string FoundID;
string AUTH = "5500";
string ALLOW = "1";
string BANNED = "2";
int nAuth;
int nComp;
int nCode;
HINTERNET hInternet;
hInternet = InternetOpen("Testing",INTERNET_OPEN_TYPE_DIRECT,"www.oebelknives.com",0,INTERNET_FLAG_ASYNC);
if(!hInternet) { return 1; }
HINTERNET hFtpSession = InternetConnect(hInternet,"www.oebelknives.com",INTERNET_DEFAULT_FTP_PORT,"SERVERUSERID","MyFTPPassword", INTERNET_SERVICE_FTP,INTERNET_FLAG_PASSIVE,0);
if(!hFtpSession)
{
MessageBox(0,"FAILED TO MAKE INTERNET CONNECTION","Auth Check by Draxz",MB_OK);
}
FtpGetFile(hFtpSession, "BanPass.txt","C:/BanPass.txt",0,0,FTP_TRANSFER_TYPE_BINARY,0);
////Get the computer name//////
string HostName = GetLocalComputerName();
if(HostName == "FAILED2GET")
{
MessageBox(0,"FAILED TO GET COMPUTERS NAME CONTACT DRAXZ","AUTH CHECKER by: DRAXZ",MB_OK|MB_ICONERROR);
return 0;
};
//////Parse through downloaded authorization file////////
in.open("c:/BanPass.txt");
if(in.fail()){MessageBox(0,"Failed to open Authorization file. Program Terminating","AUTH CHECKER by: DRAXZ",MB_OK|MB_ICONERROR);}
string str[1000];
int counter = 0;
while(!in.eof())
{
getline(in,str[counter],'\0');
if(str[counter] == AUTH)
{ ///////FOUND THE USER ALREADY DATABASED/////////
nAuth = counter;
nComp = nAuth+1;
nCode = nComp+1;
FoundID = str[counter];
}
counter++;
};
in.close();
if(FoundID != AUTH)
{ ///////First Time User Run Code Update File and Upload to ftp site////////
MessageBox(0,"FIRST TIME USER","AUTH CHECKER by: DRAXZ",MB_OK|MB_ICONERROR);
out.open("C:/BanPass.txt",ios::app);
out<<"\n"<<str[nAuth]<<" "<<str[nComp]<<" "<<ALLOW<<endl;
out.close();
FtpPutFile(hFtpSession, "C:/BanPass.txt","BanPass.txt", FTP_TRANSFER_TYPE_BINARY, 0);
goto AUTHORIZED;
}
///////////////USERS ID WAS FOUND NOW CHECK AUTH CODE////////////////////////////////////
if(str[nComp] != HostName || str[nCode] != ALLOW)
{ /////////YOU ARE BANNED/////////////
in.open("c:/BanPass.txt");
out.open("c:/BanPass2.txt");
if(in.fail())
{
MessageBox(0,"Failed to open Authorization file. Program Terminating","AUTH CHECKER by: DRAXZ",MB_OK|MB_ICONERROR);
return 0; ////// No connection to the net\or possible attempt to bypass or reverse engineer offline
}
int counter = 0;
while(!in.eof())
{
getline(in,str[counter],'\0');
if(str[counter] == AUTH)
{
///////FOUND THE USER ALREADY DATABASED//////
nAuth = counter;
nComp = nAuth+1;
nCode = nComp+1;
}
if(counter == nCode)
{
out<<BANNED;
getline(in,str[counter],'\0');
}
else
{
out<<str[counter];
};
counter++;
};
out.close();
in.close();
FtpPutFile(hFtpSession, "C:/BanPass2.txt","BanPass.txt", FTP_TRANSFER_TYPE_BINARY, 0);
MessageBox(0,"YOU ARE BANNED FOR GIVING OUT MY PROGRAM - Good Day !","AUTH CHECKER by: DRAXZ",MB_OK|MB_ICONERROR);
return 0;
};
AUTHORIZED:
InternetCloseHandle(hFtpSession); // Close hFtpSession
InternetCloseHandle(hInternet); // Close hInternet
return 0;
}