Convert C++ to PHP
Posted: Mon Nov 30, 2009 8:48 pm
A while ago I wrote a short program in C++....
I thought, why not post a form page with this bolted onto the POST. I am new to PHP.
A form is easy in any Windows Web tool. They all have menu tools to pic from.
So given a form with say a variable called user_URL or something like that, or even the default name or whatever. Once I have that variable I wanted to emulate the behaviors as above.
The program opens a browser in Windows and assigns the given URL to HTTP GET. The return page is a brief pass/fail. The sleep call is to slow the process down as the operators' server cannot handle the speed.
I do not really need to see the result, just get each URL and dump it. With sufficient delays it works fine. I used a browser call to "see" errors so I could debug the code.
Code: Select all
#include "windows.h"
#include <string>
std::string arg;
std::string sitemap = "/sitemap.xml";
bool hres;
const int sites = 4;
const int hosts = 6;
std::string URLlist[sites] = {
"computer-chess.dyndns.biz",
"contract-developer.dyndns.biz",
"econ.dyndns.biz",
"vegan.dyndns.biz",
};
std::string API[hosts] = {
"webmaster.live.com/webmaster/ping.aspx?siteMap=",
"search.yahooapis.com/SiteExplorerService/V1/updateNotification?appid=YahooDemo&url=",
"www.google.com/webmasters/tools/ping?sitemap=",
"submissions.ask.com/ping?sitemap=",
"api.moreover.com/ping?sitemap=",
"www.bing.com/webmaster/ping.aspx?sitemap="
};
void main() {
for (int i = 0; i < hosts; i++) {
for (int j = 0; j < sites; j++) {
arg = API[i];
arg += "http://";
arg += URLlist[j];
arg += sitemap;
ShellExecute(NULL, "open", arg.c_str(), NULL, NULL, SW_SHOWNORMAL);
Sleep(10000); // 10 seconds, so servers do not balk
}
};
// Zap the browser, easy as its the foreground task, no need to hunt it down
hres = PostMessage(GetForegroundWindow(), WM_CLOSE, NULL, NULL);
}
A form is easy in any Windows Web tool. They all have menu tools to pic from.
So given a form with say a variable called user_URL or something like that, or even the default name or whatever. Once I have that variable I wanted to emulate the behaviors as above.
The program opens a browser in Windows and assigns the given URL to HTTP GET. The return page is a brief pass/fail. The sleep call is to slow the process down as the operators' server cannot handle the speed.
I do not really need to see the result, just get each URL and dump it. With sufficient delays it works fine. I used a browser call to "see" errors so I could debug the code.