Exemple #1
0
void ReminderDialog::OnsendBtClick(wxCommandEvent& event)
{
	if (feedbackEdit->GetValue().empty() || !feedbackWritten ) {
		gd::LogMessage(_("You didn't entered any feedback! :O"));
		return;
	}
    wxString report;
    report += "User mail: "+mailEdit->GetValue()+"\n";
    report += "Feedback: "+feedbackEdit->GetValue()+"\n";
    report.Replace("&", "%26");

    wxString encodedReportURI = wxURI("www.compilgames.net/feedback/send.php?msg="+report).BuildURI();
    wxURI requestURI(encodedReportURI);
    std::cout << "Sending feedback with these data:" << requestURI.GetQuery() << std::endl;

    // Create request
    sf::Http Http;
    Http.setHost("http://www.compilgames.net");
    sf::Http::Request request;
    request.setMethod(sf::Http::Request::Post);
    request.setField("Content-Type", "application/x-www-form-urlencoded");
    request.setUri("/feedback/send.php");
    request.setBody(gd::ToString(requestURI.GetQuery()));

    // Send the request
    sf::Http::Response response = Http.sendRequest(request, sf::seconds(5));

    if (response.getStatus() != sf::Http::Response::Ok)
        std::cout << "Unable to connect to the server for sending the feedback!" << std::endl;
    else {
        gd::LogMessage(_("Thanks for your feedback!"));
        sendBt->Disable();
    }
}
ServiceHandler *VHostServiceDispatcher::FindServiceHandler(Context &ctx)
{
	StartTrace(VHostServiceDispatcher.FindServiceHandler);
	String requestVhostWithPort(ctx.Lookup("header.HOST", ""));
	String requestVhost(requestVhostWithPort.SubString(0, requestVhostWithPort.StrChr(':')));
	Trace("request HOST [" << requestVhost << "]");
	String requestURI(ctx.Lookup("REQUEST_URI", ""));
	Trace("request URI [" << requestURI << "]");
	ServiceHandler *sh = ServiceHandler::FindServiceHandler(requestVhost);
	if ( sh ) {
		Anything query(ctx.GetQuery());
		query["VHost"] = requestVhost;
		query["EntryPage"] = requestURI;
		// allow finding URIPrefix2ServiceMap in our own config too
		ctx.Push("ServiceHandler", sh);
		ROAnything roaURIPrefixList;
		ServiceHandler *pfxService = 0;
		if ( (pfxService=findServiceBasedOnLongestURIPrefixMatch(ctx, requestURI)) != 0 ) {
			sh = pfxService;
			query["URIPrefix"] = requestURI;
		}
		query["Service"] = sh->GetName();
		String strKey;
		ctx.Pop(strKey);
		SubTraceAny(query, query, "Query for service");
		return sh;
	}
	return RendererDispatcher::FindServiceHandler(ctx);
}
String RendererDispatcher::FindServiceName(Context &ctx) {
	StartTrace(RendererDispatcher.FindServiceName);
	ROAnything uriPrefixList(ctx.Lookup("URIPrefix2ServiceMap"));
	String requestURI(ctx.Lookup("REQUEST_URI", ""));
	Anything query(ctx.GetQuery());
	SubTraceAny(uriPrefixList, uriPrefixList, "Service Prefixes: ");
	long matchedPrefix = FindURIPrefixInList(requestURI, uriPrefixList);
	if (matchedPrefix >= 0) {
		String service;
		Renderer::RenderOnString(service, ctx, uriPrefixList[matchedPrefix]);
		query["Service"] = service;
		query["URIPrefix"] = uriPrefixList.SlotName(matchedPrefix);
		SubTraceAny(query, query, "Query: ");
		Trace("Service [" << service << "]");
		return service;
	} else if (uriPrefixList.GetSize() > 0) {
		query["Error"] = String("Service[").Append(requestURI.SubString(0, requestURI.StrChr('/', 1))).Append("]NotFound");
	}
	String defaultHandler(ServiceDispatcher::FindServiceName(ctx));
	Trace("Service:<" << defaultHandler << ">");
	return defaultHandler;
}