Esempio n. 1
0
void WebServerManager::getLoginPage(string& p_out)
{
	const string& l_webserver = STRING(WEBSERVER);
	string pagehtml = GetTplFile("header.html");
	pagehtml += GetTplFile("login.html");
	pagehtml += GetTplFile("footer.html");
	TplSetParam(pagehtml, "TITLE", getFlylinkDCAppCaption() + " " + l_webserver + " - " + STRING(WEBSERVER_LOGIN_PAGE_NAME));
	TplSetParam(pagehtml, "THEME_PATH", "FlylinkDC");
	TplSetParam(pagehtml, "META", "");
	TplSetParam(pagehtml, "APPNAME", getFlylinkDCAppCaption() + " " + l_webserver);
	TplSetParam(pagehtml, "LANG_USERNAME", STRING(SETTINGS_SOCKS5_USERNAME));
	TplSetParam(pagehtml, "LANG_PASSWORD", STRING(PASSWORD));
	TplSetParam(pagehtml, "LANG_LOGIN", STRING(LOG_IN));
	
	p_out = "HTTP/1.0 200 OK\r\nContent-Type: text/html\r\nContent-Length: " + Util::toString(pagehtml.length()) + "\r\n\r\n";
	p_out += pagehtml;
}
Esempio n. 2
0
int
UPNPCheckDlg::run()
{

	static const string description = getFlylinkDCAppCaption();
	// description += "Transfer port ";
	
	if (!_needUPNP)
	{
		setStage(STRING(UPNPCHECKDLG_PORT_CHECK));//  "Checkning Ports..."
		success(CheckPorts(_isTCPOk, _isUDPOk));
		return 1;
	}
	try
	{
		setStage(STRING(UPNPCHECKDLG_MINI_INIT));//  "Checkning MiniUPNP..."
		string url;
		string service;
		if (MiniUPnPc_init(url, service, m_device))
		{
			setStage(STRING(UPNPCHECKDLG_MINI_OPEN));// "Open ports in MiniUPNP..."
			// Open Ports
			bool isSuccess = false;
			bool portTestResult = false;
			string tcpDesc = description + "Transfer port (" + Util::toString(_tcp) + " TCP)";
			if (MiniUPnPc_add(_tcp, "TCP", tcpDesc, service, url))
			{
				string udpDesc = description + "Search port (" + Util::toString(_udp) + " UDP)";
				if (MiniUPnPc_add(_udp, "UDP", udpDesc, service, url))
				{
					if (_needPortCheck)
					{
						_isTCPOk = false;
						_isUDPOk = false;
						portTestResult = CheckPorts(_isTCPOk, _isUDPOk);
					}
					isSuccess = true;
					MiniUPnPc_remove(_udp, "UDP", service, url);
				}
				MiniUPnPc_remove(_tcp, "TCP", service, url);
				if (isSuccess)
				{
					success(portTestResult);
					return 1;
				}
			}
		}
	}
	catch (const Exception& /*e*/) {}
	
	try
	{
		setStage(STRING(UPNPCHECKDLG_WIN_INIT)); //"Checkning WinUPNP..."
		IUPnPNAT* pUN = NULL;
		bool isSuccess = false;
		bool portTestResult = false;
		if (WinUPnP_init(pUN))
		{
			setStage(STRING(UPNPCHECKDLG_WIN_OPEN));// "Open ports in WinUPNP..."
			if (WinUPnP_add(_tcp, "TCP", description, pUN))
			{
				if (WinUPnP_add(_udp, "UDP", description, pUN))
				{
					if (_needPortCheck)
					{
						_isTCPOk = false;
						_isUDPOk = false;
						portTestResult = CheckPorts(_isTCPOk, _isUDPOk);
					}
					isSuccess = true;
					WinUPnP_remove(_udp, "UDP", pUN);
				}
				WinUPnP_remove(_tcp, "TCP", pUN);
			}
			WinUPnP_uninit();
			if (isSuccess)
			{
				success(false);
				return 1;
			}
		}
	}
	catch (const Exception& /*e*/) {}
	
	if (_needPortCheck)
	{
		setStage(STRING(UPNPCHECKDLG_PORT_CHECK));//  "Checkning Ports..."
		CheckPorts(_isTCPOk, _isUDPOk);
	}
	
	failed();
	return 0;
}